To return a result set from a SQL stored procedure, you need to:
1) Define your procedure as returning a result set
2) Declare a cursor with the desired SELECT statement
3) Open that cursor
4) Set result sets and return
Here is a quick example:
----------------------------------
CREATE PROCEDURE myproc
RESULT SETS 1
LANGUAGE SQL
BEGIN
DECLARE report CURSOR FOR
SELECT field1, field2, ...
FROM file
WHERE <desired conditions>
ORDER BY <desired key fields>;
OPEN report;
SET RESULT SETS CURSOR report;
END;
----------------------------------
It has been a while since I've worked with BIRT, but I do have java programs
using JDBC and JT400 to deal with results sets returned from similar stored
procedures and they work just fine. You can also define the procedure to
accept
parameters and use those parameters in your SELECT statement.
Hope this helps!
Richard
-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx]
On Behalf Of James Lampert
Sent: Tuesday, April 19, 2011 1:19 PM
To: Java Programming on and around the IBM i
Subject: BIRT apparently doesn't like UDTFs, but likes stored procedures
that return a result set. But how?
BIRT (which uses JDBC and JT400) doesn't appear to like UDTFs. But it
seems to like Stored Procedures that return a result set.
Most of the examples I've seen simply have a SELECT (without an INTO
clause) in the stored procedure. But DB2/400 doesn't seem to like
SELECTS without INTO clauses in stored procedures.
Then there is at least one example I've seen that uses a cursor as a
parameter, but that doesn't look very promising for DB2/400, either.
Can somebody point me in the right direction here?
--
JHHL
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.