Re: procedure stored
Posted in 2004
Araujo wrote:
> I created the following procedure stored:
>
> create procedure sp_selectin(incoditicu char(30000))
> returning integer, char(50) ;> define p_coditicu integer ;
> define p_nombticu char(50);
> foreach
> select coditicu, nombticu
> into p_coditicu, p_nombticu
> from tticu
> where coditicu in (incoditicu)
> return p_coditicu, p_nombticu with resume ;> end foreach;
> end procedure;
>
> incoditicu -> is sequence of number that I'll use in 'where coditicu in
> (incoditicu)' sentences.
>
> But, the problems is when I call to sp_selectin procedure an string like ...
>
> String coditicu = "2,4,5";
>
> {call sp_coditicu(" + coditicu + ")}
>
> The procedure understand it how different arguments.
>
> What can I do?
What you're trying to do is called Dynamic SQL, and SPL (Stored
Procedure Language) does not support it. You could get yourself the
Dynamic SQL datablade - assuming you have IDS 9.30 or 9.40 (well, 9.x,
but you shouldn't be using an x < 30). Failing that, you can play
clever tricks with default arguments.
--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/