无法在 Firebird 2.5 中声明变量,为什么?

发布于 2024-10-15 10:13:49 字数 312 浏览 15 评论 0原文

我有一个单行查询:

DECLARE VARIABLE var_SecondsOfTime INTEGER;

但是运行查询后我收到此消息:

引擎错误(代码 = 335544569): 动态 SQL 错误。 SQL错误代码= -104。令牌未知 - 第 1 行第 9 列。变量。

SQL 错误(代码 = -104):无效 令牌。

我在互联网上到处查看,所有示例都显示了我正在使用的相同声明样式。

怎么了?

I have a one line query:

DECLARE VARIABLE var_SecondsOfTime INTEGER;

But after running the query I am getting this message:

Engine Error (code = 335544569):
Dynamic SQL Error. SQL error code =
-104. Token unknown - line 1, column 9. VARIABLE.

SQL Error (code = -104): Invalid
token.

I've looked everywhere on the Internet and all examples showing the same declaration style which I am using.

What is wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

家住魔仙堡 2024-10-22 10:13:49

Firebird 2.5 支持执行由 执行块< 包围的代码块/strong> 语句,试试这个:

set term ^ ;

EXECUTE BLOCK 
AS
   DECLARE VARIABLE var_SecondsOfTime INTEGER;

BEGIN
  SELECT 1 from RDB$DATABASE into var_SecondsOfTime ;
END
^

set term ; ^

我发出了选择,因为我很确定不可能执行空块,请自己尝试删除选择。

isql 运行块

编辑
我原来的选择对于一个块来说是无效的,我添加了 into 子句来收集结果。我从未使用过 firebird maestro,但它现在在 isql 上完美运行,如图所示。

Firebird 2.5 supports execution of code blocks surrounded by a execute block statement, try this:

set term ^ ;

EXECUTE BLOCK 
AS
   DECLARE VARIABLE var_SecondsOfTime INTEGER;

BEGIN
  SELECT 1 from RDB$DATABASE into var_SecondsOfTime ;
END
^

set term ; ^

I issued the select because I'm pretty sure it is not possible to execute an empty block, try this by yourself removing the select.

isql running the block

Edit
My original select was invalid for a block, I added the into clause to collect the result. I never used firebird maestro, but it now works perfectly on isql, as shown.

甜味拾荒者 2024-10-22 10:13:49

试试这个:

set term ^ ;

EXECUTE BLOCK 
AS
   DECLARE VARIABLE var_SecondsOfTime INTEGER;

BEGIN
  SELECT  1 from RDB$DATABASE  into :var_SecondsOfTime ;
END^

set term  ;^

第二组术语需要在克拉之前加分号。

Try this:

set term ^ ;

EXECUTE BLOCK 
AS
   DECLARE VARIABLE var_SecondsOfTime INTEGER;

BEGIN
  SELECT  1 from RDB$DATABASE  into :var_SecondsOfTime ;
END^

set term  ;^

The second set term needs the semi colon before the carat.

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