更新存储过程因查询而失败

发布于 2024-10-21 20:53:28 字数 1055 浏览 8 评论 0原文

数据库: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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

屌丝范 2024-10-28 20:53:28

执行此操作

query.ParamCheck := False;
query.Params.Clear;
query.SQL.Clear;

在分配 SQL 之前 。完成 DDL 更新后,请不要忘记将 ParamCheck 恢复为 True

Do

query.ParamCheck := False;
query.Params.Clear;
query.SQL.Clear;

before you assign the SQL. Don't forget to revert ParamCheck to True once you're done updating DDL.

神回复 2024-10-28 20:53:28

您已经声明了一个变量 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文