1

数据库:Interbase 6.5 连接:与 IBX 或 BDE 相同的结果 程序是用 delphi 7 编写的

我尝试更新 th 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,它可以工作。

怎么了?

更新:

在原始代码中,它是 decalred 变量!

更正:

query.sql.add('into :helpint;');    <------ here is line xx
query.sql.add('if (helpint>0) then myresult = 1;');
4

2 回答 2

2

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

在分配 SQL 之前。完成更新 DDL 后不要忘记恢复ParamCheckTrue

于 2011-03-11T11:16:25.417 回答
0

您已经声明了一个变量 HELPINT,因此您必须使用 HELPINT 作为变量,而不是标记行上的 VARIABLE 以及下一行。

于 2011-03-11T10:38:14.010 回答