Stored procedure on Sybase returns empty result set.

Article ID: 786
Last updated: 05 Feb, 2008
Article ID: 786
Last updated: 05 Feb, 2008
Revision: 1
Views: 9486
Posted: 26 Jun, 1997
by Dean J.
Updated: 05 Feb, 2008
by Dean J.
Problem


I have a stored procedure on Sybase that returns a return value and result sets. Whenever I test the return value first, my result set is empty.


Cause


This has to do with the way the Sybase DBLibrary processes result sets and return values (or output parameters). Result sets and return values can only be accessed in a manner similar to that of a singly-linked list. It is not possible to access the return value without iterating through the complete result set first. This is not a DBTools.h++ bug.


Action


When returning a return value or output parameter and a result sets from a Sybase stored procedure, it is very important to process the result first, then get the return value or the output parameters. Result sets can be stored temporarily into a memory table first and be processed later.

Sample Code:

            RWDBDatabase database =
RWDBManager::database("SYBASE","user","pwd","DB");
RWDBConnection conn = database.connection();
// test proc returns result sets and value
RWDBStoredProc sproc=database.storedProc("testproc");
RWDBResult res = sproc.execute(conn);
RWDBMemTable memTab(res.table().reader(conn));
if(sproc.returnValue().asInt()==1)
{
// Process results here from the memTab
}


This article was:   Helpful | Not helpful
Report an issue
Article ID: 786
Last updated: 05 Feb, 2008
Revision: 1
Views: 9486
Posted: 26 Jun, 1997 by Dean J.
Updated: 05 Feb, 2008 by Dean J.

Others in this category