If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > Dynamic sql in informix stored proecedure

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-09-04, 06:28
Puneet Jaggi Puneet Jaggi is offline
Registered User
 
Join Date: Aug 2004
Posts: 1
Dynamic sql in informix stored proecedure

i want to create a procedure in informix in which table name is in a variable (strTable) and i want to retrieve the records from that table. Later i will link this procedure to crystal report to create a report of the records.

eg.
Define strTable Varchar(30);
Let strTable = "Employee";
Select * from strTable;

I tried dynamic sql statements "prepare" and "execute" in the procedure but it didn't work.
eg.
CREATE PROCEDURE tempProc()
RETURNING
VarChar(30);
DEFINE tmpstr VARCHAR(255);
Define rgn varchar(255);
Let tmpstr='Employee';

foreach curTemp For
prepare s1 from "Select Region_name from ?"
execute s1 using tmpstr
WITH RESUME;
END FOREACH
END PROCEDURE;

pls help me if u know any solution to this problem.
Regards,
Puneet
(puneetjaggi@indiatimes.com)
Reply With Quote
  #2 (permalink)  
Old 08-10-04, 10:37
Big Kahuna Big Kahuna is offline
Registered User
 
Join Date: Jan 2003
Posts: 30
SPL does not support Dynamic SQL

Hi,

Informix Stored procedure language does not support Dynamic SQL.

You have to write a C-program and use a SQLDA or Descriptor area.

You can also use shell scripting and use environment variable in all inline sql statements.

Eg

MYTABLE="sysusers"
dbaccess -e somedb <<EOF

unload to /tmp/$MYTABLE.unl
select * from $MYTABLE;

EOF
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On