Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic sql in stored procedure

Status
Not open for further replies.

patriceguic

Programmer
Feb 26, 2007
2
FR
Hello,

I don't know how fetch a cursor whose request is contained in a variable. The following code is ok in a 4GL but not in a stored procedure. I use version 9.40 of informix.

Thank you for your help

Code:
CREATE PROCEDURE sp_get_nom_calc_sect(pi_instance VARCHAR(100))
RETURNING       CHAR(2);
 
DEFINE  ls_sql                  char(100);
DEFINE  po_cd_act_sect          char(2);
 
 
let ls_sql = "SELECT cd_sect_act from " || pi_instance;
 
prepare statement2 FROM ls_sql
declare cur_calc_sect cursor FOR statement2
FOREACH cur_util INTO po_cd_act_sect
 
        RETURN  po_cd_act_sect WITH RESUME;
 
END FOREACH
 
END PROCEDURE;
 
Unfortunately, the Informix SP language does not support building dynamic cursors. I've often wanted to this myself.

Since you are running 9.4, have you considered investing in the datablade technology. I've never used it, but I hear that the abilities are far superior to SP.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top