I would like to input an array parameter of IDs to Firebird Stored Procedure.
:INPUT_LIST_ID = [1, 2, 12, 45, 75, 45]
I\'m need
AFAIK no, thats not possible. While Firebird does have array data type, support for it is rudimentary and use of arrays is generally not recommended. I think the easiest solution would be to pass the array as (comma separated) string and then use the for execute statement statement to get the resultset, something like
create procedure CITY (INPUT_LIST_ID varchar(1024))
returns( ... )
as
begin
for execute statement
'select ... from T where ID_CITY IN ('|| INPUT_LIST_ID ||')' into ...
do begin
suspend;
end
end
This means however that the statement you use to get the result also changes, instead of WHERE
you would use the parameter of the stored procedure CITY
:
SELECT * FROM CITY('1, 2, 12, 45, 75, 45')
Another option to send the parameter list is to use global temporary table. This has the pro that you can send huge number of IDs without exceeding the maximum allowed statements size but it is more work to set up the call...
create global temporary table SP_CITY_PARAMS (
id int not null primary key
)
on commit delete rows;
create procedure CITY
returns( ... )
as
begin
for select ... from T where ID_CITY IN (
select id from SP_CITY_PARAMS
) into ...
do begin
suspend;
end
end