当前位置: 代码迷 >> PB >> 请教怎么传递参数给存储过程
  详细解决方案

请教怎么传递参数给存储过程

热度:65   发布时间:2016-04-29 08:46:38.0
请问如何传递参数给存储过程?
数据库是SQL ANYWHERE 12 开发版

存储过程代码如下:
SQL code
ALTER PROCEDURE "DBA"."update_ifenddate"()BEGIN   DECLARE @ld_nowdate DATE ;   UPDATE DBA.dangan set ifenddate = 1 WHERE [email protected]_nowdate;END


POWERBUILDER 中的执行代码如下:

C/C++ code
ld_nowdate = date(today() , 'yyyy-mm-dd')declare sp_update_ifenddate procedure for update_ifenddate    @ld_nowdate = :ld_nowdate;   execute sp_update_ifenddate;   if sqlca.sqlcode = 0 then        commit;   else      messagebox('错误信息:' , sqlca.sqlerrtext)      rollback;          end if


结果MESSAGEBOX的错误信息是:
[sql anywhere] [email protected]_nowdate'
请问:SQL ANYWHERE12 [email protected]_nowdate , 谢谢!

------解决方案--------------------
SQL code
ALTER PROCEDURE "DBA"."update_ifenddate"(IN   @ld_nowdate DATE )BEGIN   UPDATE DBA.dangan set ifenddate = 1 WHERE [email protected]_nowdate;END
------解决方案--------------------
ALTER PROCEDURE "DBA"."update_ifenddate"()

你的存储过程后面没有定义参数?

ALTER PROCEDURE "DBA"."update_ifenddate" @ld_nowdate date


SQL code
B. 使用带有参数的简单过程下面的存储过程从四个表的联接中只返回指定的作者(提供了姓名)、出版的书籍以及出版社。该存储过程接受与传递的参数精确匹配的值。USE pubsIF EXISTS (SELECT name FROM sysobjects          WHERE name = 'au_info' AND type = 'P')   DROP PROCEDURE au_infoGOUSE pubsGOCREATE PROCEDURE au_info    @lastname varchar(40),    @firstname varchar(20) AS SELECT au_lname, au_fname, title, pub_name   FROM authors a INNER JOIN titleauthor ta      ON a.au_id = ta.au_id INNER JOIN titles t      ON t.title_id = ta.title_id INNER JOIN publishers p      ON t.pub_id = p.pub_id   WHERE  au_fname = @firstname      AND au_lname = @lastnameGO
  相关解决方案