|
I am not sure if having two RETURNs is supported.do
You shouldn't have to have a global temporary table at all.
Check out following two links for couple of good examples how to create
UDTFs:
By Kent Milligan and David Andruchuk:
http://www-03.ibm.com/systems/i/software/db2/pdf/ExternalUDTF.pdf
By Scott Klement:
http://systeminetwork.com/article/udtf-ifs-directories
HTH, Elvis
Celebrating 11-Years of SQL Performance Excellence on IBM i5/OS and OS/400
www.centerfieldtechnology.com
-----Original Message-----
Subject: SQL UDTF on iSeries - executing dynamic SQL or varying
selectstatements???
We're am working on a SQL UDTF on our iSeries and we're having trouble
executing dynamic SQL or varying select statements. The only method we've
been able to get to work is with the use of a global temporary table.
something like this:
BEGIN
IF var=x THEN
INSERT INTO SESSION.TEMP TABLE
SELECT * FROM blah blah blah;
ELSEIF var=y THEN
INSERT INTO SESSION.TEMP TABLE
SELECT * FROM blah blah blah;
END IF;
RETURN SELECT a, b, c FROM SESSION.TEMP TABLE;
END;
This works but I really don't want to use the temp table. You can't drop
the session table from the UDTF - you pretty much have to wait for the
connection to drop so the table will be dropped. Is there another way to
this?a
We've tried (without success) the statement below but the RETURN statement
has to be your last statement.
BEGIN
IF var=x THEN
RETURN SELECT * FROM blah blah blah;
ELSEIF var=y THEN
RETURN SELECT * FROM blah blah blah;
END IF;
END;
We've also tried building a SQL string, executing it, and passing it into
cursor...but again, the last statement has to return a TABLE.list
Anyone out there done this without a temp table?
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
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.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.