Unix Technical Forum

procedure stored

This is a discussion on procedure stored within the Informix forums, part of the Database Server Software category; --> Hi... I created the following procedure stored: create procedure sp_selectin(incoditicu char(30000)) returning integer, char(50) ; define p_coditicu integer ; ...


Go Back   Unix Technical Forum > Database Server Software > Informix

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 10:18 PM
Araujo
 
Posts: n/a
Default procedure stored


Hi...

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?

Thank you.
sending to informix-list
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 10:18 PM
Jonathan Leffler
 
Posts: n/a
Default Re: procedure stored

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/

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:08 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com