Kjell Rilbe
Kjell Rilbe

Reputation: 1499

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

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?

Upvotes: 1

Views: 298

Answers (1)

Mark Rotteveel
Mark Rotteveel

Reputation: 108994

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.

Upvotes: 2

Related Questions