× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 3/26/2013 5:48 PM, Anderson, Kurt wrote:
I have a stored procedure and it was returning an output parameter. People are whining because of the effort they have to go through to consume an output parameter (in Java). Ok, fine (yet here I am, going through 'effort,' but I like to learn so I guess that's the difference). So I'm trying to switch the stored procedure to return the SmallInt value as a single result set. However it doesn't seem to be working.

In the create procedure statement, after the parameter list, I have:
Result Sets 1
Language SQL

At the very bottom of the procedure (just before the "End"), I have:
DECLARE rsCursor CURSOR FOR SELECT rtnTracking FROM sysibm/sysdummy1;
OPEN rsCursor;
SET RESULT SETS CURSOR rsCursor;

rtnTracking is a local variable:
Declare rtnTracking SmallInt;

First, I'm getting an error.
Second, I hope there's a better way to set a local variable to a result set w/o doing a "fake" select.

The error (on the Declare Cursor line):
Position 13 Token RSCURSOR was not valid. Valid tokens: GLOBAL.

I'm at IBM i 7.1.

You don't have to make a fake SQL call in order to return a result set;
You can return an array - even an array of one element.

// this is the result set we'll be returning
// the names here are what the caller will see
drs ds dim(1000) qualified
d count 10i 0
d name 50 varying

// here's the part that tells the database manager how to handle
// the result set
exec sql
set result sets array :RS for :ROWCOUNT rows;

*inlr = *on;

--buck

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.