更新存储过程因查询而失败
数据库:Interbase 6.5 连接:与IBX或BDE结果相同 程序是用delphi 7编写的
我尝试更新sp。结果“Token Unknown -line xx, char yy” Line xx 和 char yy 指向第一个变量。
示例:
query.sql.add('ALTER PROCEDURE');
query.sql.add('MYPROCEDURE (mypkey integer)');
query.sql.add('returns (myresult integer)');
query.sql.add('as');
query.sql.add('declare variable helpint integer;');
query.sql.add('BEGIN');
query.sql.add('select count(bla)');
query.sql.add('from mytable');
query.sql.add('where pkey=:mypkey');
query.sql.add('into :helpint;'); <------ here is line xx
query.sql.add('if (helpint>0) then myresult = 1;');
query.sql.add('suspend;');
query.sql.add('END');
try
query.ExecSQL;
except
on E:Exception do
begin
E.Message := E.Message +#13#10+query.SQL.Text;
raise;
end;
如果我使用 ibconsole 更新 sp,它就可以工作。
出了什么问题吗?
更新:
在原始代码中,它是贴花变量!
更正:
query.sql.add('into :helpint;'); <------ here is line xx
query.sql.add('if (helpint>0) then myresult = 1;');
Database: Interbase 6.5
Connection: the same result with IBX or BDE
Program is written with delphi 7
I try to update th sp. The result "Token unknown -line xx, char yy" Line xx and char yy points to the first variable.
Example:
query.sql.add('ALTER PROCEDURE');
query.sql.add('MYPROCEDURE (mypkey integer)');
query.sql.add('returns (myresult integer)');
query.sql.add('as');
query.sql.add('declare variable helpint integer;');
query.sql.add('BEGIN');
query.sql.add('select count(bla)');
query.sql.add('from mytable');
query.sql.add('where pkey=:mypkey');
query.sql.add('into :helpint;'); <------ here is line xx
query.sql.add('if (helpint>0) then myresult = 1;');
query.sql.add('suspend;');
query.sql.add('END');
try
query.ExecSQL;
except
on E:Exception do
begin
E.Message := E.Message +#13#10+query.SQL.Text;
raise;
end;
If I update the sp with ibconsole, it works.
Whats going wrong?
Update:
In the original code it is the decalred variable!
correction:
query.sql.add('into :helpint;'); <------ here is line xx
query.sql.add('if (helpint>0) then myresult = 1;');
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
执行此操作
在分配 SQL 之前 。完成 DDL 更新后,请不要忘记将
ParamCheck
恢复为True
。Do
before you assign the SQL. Don't forget to revert
ParamCheck
toTrue
once you're done updating DDL.您已经声明了一个变量 HELPINT,因此您必须在标记行以及下一行上使用 HELPINT 作为变量,而不是 VARIABLE。
You have declared a variable HELPINT, so you have to use HELPINT as variable, not VARIABLE on the marked line, and on the next one too.