Subject RE: [firebird-support] Dynamic Input Parameter in Stored Procedure
Author Svein Erling Tysvær
>Hi all,
>
>Is this possible to create stored proc with dynamic parameter as an input?
>
>For example, I have a table like this :
>
>id value
>== =====
>1 'A'
>2 'B'
>3 'C'
>4 'D'
>5 'E'
>
>How to create stored proc to returns values from above table but with dynamic id as an input?
>
>For ex, how to return values, if with id in (1,2) or id in (1,2,5), etc.
>
>In select statement, it will equal to statement like this :
>select value from table where id in (1,2) or select value from table where id in (1,2,5)

If you mean a dynamic number of parameters, then no, this is not possible to do directly. Of course, in a stored procedure you could take one VARCHAR as an input parameter and then split up and check individual parts in a loop, e.g. something like

I = 1;
iLength = length(MyVarCharParameter
While (I <= ilength) do
begin
I2 = cast(substring(MyVarCharParameter) from I for 1) as Integer;
FOR SELECT Value FROM MyTable WHERE ID = I2 INTO :MyOutputParameter do
SUSPEND;
End

HTH,
Set