1

In a Firebird execute block I want to execute a singleton select and assign multiple columns to a set of parameters/variables. I know a single value can be assigned with :param = (select ...) and that I can also loop through a result set and assign multiple params with for select ... into :p1, :p2....

But I don't want a loop, because it's a singleton select, but I do want to assign multiple parameters from that select.

How is that done?

Kjell Rilbe
  • 1,331
  • 14
  • 39

1 Answers1

2

You can use select .. into:

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

In the into clause, it is not necessary to prefix the variables with :.

Depending on the client used, you may also need to include a suspend after the select statement to see the values in the client.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197