Problem to run insert

Hi,
I get this error

Error message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' store_dscr = '033002',  stockout_time = current_timestamp' at line 1
Error number: 1064

when running "Insert" against Mysql database. why?
LVL 11
HuaMin ChenProblem resolverAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gurpsbassiCommented:
please post your entire sql statement
0
HuaMin ChenProblem resolverAuthor Commented:
Here is the relevant query

				sql = "insert into conv_store.package_vg set " +
						" in_time = current_timestamp, " +
						" mod_time = current_timestamp, " +
						" in_by = " + GetSqlString(cUser) + ", " +
						" mod_by = " + GetSqlString(cUser) + ", " +
						" status = 'store_rcv', " +
						//" store = " + GetSqlString(cConvStoreCode) + ", " +
						" waybill_num = " + GetSqlString(cWaybill) + ", " +
						" price = " + GetSqlString(cFeeAmt) + "," +
						" remote_charge = " + GetSqlString(TransferFee) + "," +
						" total_price = (" + GetSqlString(TransferFee) + " + " + GetSqlString(cFeeAmt) + ")," +
						" phone = " + cMobile + "," +
						//" sms_time = " + cStockOutTime + ", " +
						//" bar_time = " + GetSqlString(cBarTime) + ", " +
						" store_dscr = " + GetSqlString(cConvStoreDscr) + ", " +
						//" store_rcv_time = " + GetSqlString(cBarTime) + ", " +
						//" stockout_time = " + cStockOutTime + ", " +
						//" stockout_time = " + GetSqlString(cBarTime) + " ";
						" stockout_time = current_timestamp ";

Open in new window

which is leading to the problem.
0
gurpsbassiCommented:
why are you using 'set' in your insert statement? Seems like you have copied it from an update statement.

You need to insert using the correct syntax for a database insert.
0
HuaMin ChenProblem resolverAuthor Commented:
Sorry, I see other Insert statement is also having " set ...", which is working fine.

And I see the correct syntax of "Insert" is also having " set ..." like

INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
    [INTO] tbl_name
    [PARTITION (partition_name,...)]
    SET col_name={expr | DEFAULT}, ...
    [ ON DUPLICATE KEY UPDATE
      col_name=expr
        [, col_name=expr] ... ]

Open in new window

0
mccarlIT Business Systems Analyst / Software DeveloperCommented:
Can you get your code to print to the console (just for debug purposes, you can remove this later) the contents of your "sql" String variable after it creates it in the code snippet you posted above. It is easier to see what it is trying to do that way.

ie. just add a       System.out.println(sql);       line just after it builds the sql string
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.