| | | | Browse by category |
Article ID: 990
Last updated: 05 Feb, 2008
Problem
When executing a stored procedure from DBTools.h++ that has an INSERT, the INSERT is not executed when that stored procedure also uses a RETURN statement. For example, the stored procedure might look like this:
When executing a stored procedure from DBTools.h++ that has an INSERT, the INSERT is not executed when that stored procedure also uses a RETURN statement. For example, the stored procedure might look like this:
CREATE PROCEDURE foo(p INT) RETURNING INT;When executed from a DBTools.h++ app using RWDBStoredProc, the row is not inserted. But when executing the stored procedure from DBACCESS, it works fine. Here is an example of what the DBTools.h++ code might look like.
INSERT INTO bar VALUES(p);
RETURN 0;
END PROCEDURE;
RWDBStoredProc sp= db.storedProc(foo);
sp.execute();
Cause
We have observed that Informix stored procedures do not commit
their results unless you be sure to read any result sets returned by
that same stored procedure. What this means in the example above,
is your DBTools application must read the returned result(s) if you
wish the INSERT to be completed. Note that when this occurs
you do not see an error returned from Informix, simply your INSERT
does not execute. The reason DBACCESS works is because
DBACCESS does retrieve the result.
Action
If your stored procedure uses the statementRETURNyou must read the returned result(s) from your DBTools.h+ application. Here is a DBTools.h++ example showing how to read a stored procedure result.RWDBStoredProc mySp= myDb.storedProc(foo);Or, if possible, removing the RETURN statement from your stored procedure should also fix it.
RWDBResult myResult = mySp.execute();
RWDBTable myResTable = myResult.table();
RWDBReader myRdr = myResTable.reader();
int myInt;
while(myRdr())
{
myRdr >> myInt;
}
This article was:
Helpful |
Not helpful
Report an issue
Article ID: 990
Last updated: 05 Feb, 2008
Revision: 1
Views: 11173
Posted: 05 Aug, 1997 by
Dean J.
Updated: 05 Feb, 2008 by
Dean J.
Others in this category
Powered by KBPublisher (Knowledge base software)