Okay I was wrong...
EXECUTE IMMEDIATE combines the basic functions of the PREPARE and EXECUTE statements. It can be used to prepare and execute SQL statements that contain neither host variables nor parameter markers.
Instead... change it to do this.
PREPARE S1 FROM @sqlstmt;
DECLARE C1 CURSOR FOR S1;
OPEN C1 USING :i_fldid;
FETCH C1 INTO :tbl;
CLOSE C1;
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Schutte, Michael D
Sent: Friday, April 29, 2011 2:27 PM
To: Midrange Systems Technical Discussion
Subject: RE: Another SQL-newbie UDF question: qualifying with a library passed as a variable
I should clarify.
Yes execute immediate does take the statement as a string. However, notice the question mark in the statement. This requires a prepare statement. Which then allows you to execute immediately using host parameters.
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of James Lampert
Sent: Friday, April 29, 2011 2:04 PM
To: Midrange Systems Technical Discussion
Subject: Re: Another SQL-newbie UDF question: qualifying with a library passed as a variable
Schutte, Michael D wrote:
sqlstmt = "select tblid from " concat trim(i_lib) concat "/FOO where dfid = ?";
prepare s1 for sqlstmt;
execute immediate into tbl using i_fldid;
Hmm. Not sure I quite get this syntax. I thought "execute immediate"
took the statement as a string.
--
JHHL
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at
http://archive.midrange.com/midrange-l.
________________________________
Notice from Bob Evans Farms, Inc: This e-mail message, including any attachments, may contain confidential information that is intended only for the person or entity to which it is addressed. Any unauthorized review, use, disclosure or distribution is strictly prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message and any attachments.
As an Amazon Associate we earn from qualifying purchases.