Re: Retrieving Stored Procedure Returns

From: Bryce (spamtrap_at_berzerker-soft.com)
Date: 09/10/04


Date: Fri, 10 Sep 2004 10:35:34 -0400

On 9 Sep 2004 16:01:53 -0700, "Xeth Waxman" <xwaxman@gmail.com>
wrote:

>Greetings experts. I'm having a problem retrieving values from a
>CallableStatement after executing a Stored procedure. The RDBMS is MS
>SQL Server 2k and the JDBC driver is JTDS 0.8.1. Here's the code I
>have:
>
>

should this be:
cs = con.prepareCall("{? = call spGetNextBatch(?,?,?,?,?,?,?,?,?)}");

the name spGetNextBatch makes the think there's an actual return value
with this stored procedure...

>cs.registerOutParameter(7, Types.INTEGER);
>cs.registerOutParameter(8, Types.INTEGER);
>cs.registerOutParameter(9, Types.INTEGER);
>cs.setString(1, "GCC");
>cs.setInt(2, 8);
>cs.setInt(3, 802);
>cs.setString(4, userName);
>cs.setString(5, batchComment);
>cs.setString(6, todayString);
>
>//everything's set - execute
>cs.execute();
>
>while (cs.getMoreResults() == true && cs.getUpdateCount()!= -1)
>{
>//processing stuff
>System.out.println("sizzling shizzle");
>}
>
>//get our values out
>int batchKey = cs.getInt(7);
>int nextBatchNo = cs.getInt(8);
>int retVal = cs.getInt(9);
>
>According to the profiler, the SP is executing and returning the
>appropriate values. However, after running this code, all three value
>(batchKey, nextBatchNo , and retVal) are all unitialized (0), which is
>incorrect. I am stumped as to what I should be looking for or fixing,
>and as always any assistance is appreciated.

--
now with more cowbell


Relevant Pages

  • Re: Poor performance when executing stored procedure
    ... If SQL Server ... has to re-compile the SP, it takes shorter time to compile a smaller stored ... Poor performance when executing stored procedure ...
    (microsoft.public.sqlserver.programming)
  • Stored procedure does not complete until result set is retrieved from ODBC
    ... I have a SQL Server Stored procedure that I am executing via ODBC. ... -- Start Code without cursor ...
    (microsoft.public.sqlserver.odbc)
  • Re: SQL/ASP - Timout Problem w/ Particular Statement
    ... inside the stored proc and i was executing one query or the other based ... > My asp page calls a stored procedure passing many parameters. ... > I used the SQL profiler to get the exact stored procedure with all ... > After executing 2-3 times the stored procedure in the Query Analyzer, ...
    (comp.databases.ms-sqlserver)
  • RE: Login failed for user foo but the SQL executed correctly
    ... Could you post the detailed error message when executing the stored ... and see under which user the stored procedure is executed. ... Is the error thrown by the stored procedure or the SQL Server 2000? ... | for user 'foo' error. ...
    (microsoft.public.sqlserver.security)
  • Re: sp_execresultset and ANSI_NULLS
    ... You can find the source code of sp_execresultset here. ... Create another sp using the source With ANSI_NULLS ON and try executing ... The problem is that no matter what I try, it creates the proc> with ANSI_NULLS OFF. ... These original>> settings are used when the stored procedure is executed. ...
    (microsoft.public.sqlserver.programming)