简体   繁体   中英

Local variable syntax error

I'm trying to create a procedure from the MySQL API in C. My query string is as follows (in the C code):

"CREATE PROCEDURE clockOut (taskID INT UNSIGNED) "
"BEGIN "
"DECLARE @username VARCHAR(8);"
"SELECT @username = userID FROM TaskItem WHERE id=taskID;"
"UPDATE TaskItem SET onClock=0,stopTime=NOW() "
"WHERE id=taskID AND userID=@username;"
"END"

This string will ultimately be transmitted with mysql_query() , which returns error code 1064, a syntax error. What have I done wrong?

正如@alk所建议的那样,我从变量中删除了@语法,并且效果很好。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM