sql - How to input an array parameter of values to Firebird Stored Procedure? -
i input array parameter of ids firebird stored procedure.
:input_list_id = [1, 2, 12, 45, 75, 45]
i'm need execute sql command:
select * city id_city in (:input_list_id)
is possible? thanks!
you use this:
select * city id_city in (select id getintegerlist('1, 2, 12, 45, 75, 45'))
you have create new firebird procedure called "getintegerlist" this:
create or alter procedure "getintegerlist"("aintegerlist" varchar(32000)) returns ( id integer ) declare variable integerlist varchar(32000); declare variable commapos integer; declare variable integerval varchar(10); begin integerlist = aintegerlist || ' '; commapos = position(',', integerlist); while (commapos > 0) begin integerval = trim(substring(integerlist 1 commapos - 1)); if (char_length(integerval) > 0) begin if (integerval similar '[0-9]*') begin id = cast(integerval integer); suspend; end end if (char_length(integerlist) > commapos) integerlist = substring(integerlist commapos + 1); else integerlist = ''; commapos = position(',', integerlist); end integerlist = trim(integerlist); if (char_length(integerlist) > 0) begin if (integerlist similar '[0-9]*') begin id = cast(integerlist integer); suspend; end end end
note, done in firebird 2.5.2.
Comments
Post a Comment