Retreive a value inside a stored procedure and use it inside that stored procedure

Posted by sai on Stack Overflow See other posts from Stack Overflow or by sai
Published on 2010-04-20T14:41:52Z Indexed on 2010/04/20 14:43 UTC
Read the original article Hit count: 544

Filed under:
|
|
|
|

delimiter // CREATE DEFINER=root@localhost PROCEDUREgetData(IN templateName VARCHAR(45),IN templateVersion VARCHAR(45),IN userId VARCHAR(45)) BEGIN set @version = CONCAT("SELECT saveOEMsData_answersVersion FROMsaveOEMsData WHERE saveOEMsData_templateName = '",templateName,"' ANDsaveOEMsData_templateVersion = ",templateVersion," AND saveOEMsData_userId= ",userId); PREPARE s1 from @version; EXECUTE S1; END // delimiter ;

I am retreiving saveOEMsData_answersVersion, but I have to use it in an IF loop, as in if the version == 1, then I would use a query, else I would use something else. But I am not able to use the version. Could someone help with this?? I am only able to print but not able to use the version for data manipulation. The procedure works fine but I am unable to proceed to next step which is the if condition.

The if condition would have something like the below mentioned.
IF(ver == 1) THEN SELECT "1"; END IF;

© Stack Overflow or respective owner

Related posts about mysql

Related posts about stored