Hello, i've a problem regarding the select stmt inside the stored procedure.
Here's my code:
[code=sql]
DELIMITER $$
DROP PROCEDURE IF EXISTS `p`.`getNames`$ $
CREATE PROCEDURE `p`.`getNames`( q varchar)
/*LANGUAGE SQL
| [NOT] DETERMINISTIC
| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }
| COMMENT 'string'*/
BEGIN
exec q;
END$$
DELIMITER ;
[/code]
i want to execute the variable q.
for ex: (from the java class)
then i'll just pass it to the stored procedure. however, that doesn't work, there's an error that says
Error Code : 1064
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 ')
/*LANGUAGE SQL
| [NOT] DETERMINISTIC
| { CONTAINS SQL | NO SQL | R' at line 1
there are certain conditions in the java class so q varies depending on the user inputs.
please help me.
Please enclose any code within the proper code tags. See the Posting Guidelines on how to do that. - moderator
Here's my code:
[code=sql]
DELIMITER $$
DROP PROCEDURE IF EXISTS `p`.`getNames`$ $
CREATE PROCEDURE `p`.`getNames`( q varchar)
/*LANGUAGE SQL
| [NOT] DETERMINISTIC
| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }
| COMMENT 'string'*/
BEGIN
exec q;
END$$
DELIMITER ;
[/code]
i want to execute the variable q.
for ex: (from the java class)
Code:
q = "select * from user where username = '"+u+"' AND name = '"+n+"';";
Error Code : 1064
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 ')
/*LANGUAGE SQL
| [NOT] DETERMINISTIC
| { CONTAINS SQL | NO SQL | R' at line 1
there are certain conditions in the java class so q varies depending on the user inputs.
please help me.
Please enclose any code within the proper code tags. See the Posting Guidelines on how to do that. - moderator
Comment