> 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)

I see two ways here:

1) As a VARCHAR input parameter in combination with using [FOR] EXECUTE 
STATEMENT 'SELECT ... WHERE ' || string || '... INTO ...'

2) By using a global temporary table (GTT): Insert the requested IDs 
into a GTT outside the SP and then JOIN the base table with the GTT in 
the SP.


-- 
With regards,
Thomas Steinmaurer
http://www.upscene.com/

Reply via email to