【发布时间】:2012-02-16 18:37:26
【问题描述】:
Below is my store procedure .please help........
BEGIN
DECLARE selectQuery VARCHAR(2000);
declare finalquery varchar(2000);
declare stmt3 varchar(2000);
SET selectQuery = 'SELECT tbl_property.intId, strAddressLine1,(select strItemName from tbl_lk_item where intId=tbl_property.intPropertyCountyTypeId) as strCountyName ,(select strItemName from tbl_lk_item where intId=tbl_property.intPropertyCountryTypeId) as strCountryName ,strpostCode,(tbl_pro_adver_matchcriteria.floatAskingPrice),tbl_pro_adver_matchcriteria.intBedrooms
FROM tbl_property LEFT OUTER JOIN tbl_pro_adver_matchcriteria on tbl_property.intId = tbl_pro_adver_matchcriteria.intPro
set finalquery =CONCAT(selectQuery,strSqlQuery,' AND tbl_property.intId=1 ');
execute finalquery;
END
当我运行存储过程并传递参数 'where tbl_property.intId=1' 时,它使过程执行失败 1243 - 为 EXECUTE 提供了未知的准备好的语句处理程序(finalquery)
我通过 select 语句检查查询结果,它给出了正确的查询并返回结果。所以请帮助我使用 Execute 语句。
【问题讨论】:
-
准备好的语句的 SQL 语法 - dev.mysql.com/doc/refman/5.1/en/…