在 Firebird 中从单个(单例)select 分配多个参数?

Assign multiple params from single (singleton) select in Firebird?

在 Firebird 执行块中,我想执行一个单例 select 并将多个列分配给一组 parameters/variables。我知道可以使用 :param = (select ...) 分配单个值,并且我还可以遍历结果集并使用 for select ... into :p1, :p2....

分配多个参数

但我不想要循环,因为它是一个单例 select,但我确实想从中分配多个参数 select。

这是怎么做到的?

您可以使用 select .. into:

execute block returns (a integer, b integer)
as
begin
  select 1, 2 from rdb$database into a, b;
end

into子句中,不需要在变量前加上:

根据所使用的客户端,您可能还需要在 select 语句之后包含一个 suspend 以查看客户端中的值。