Re: Invalid character???
Date: Wed, 20 Aug 2008 13:51:04 -0400
Message-ID: <03moa493ps1g4dp3e3dedgql1j8gkeo0ik@4ax.com>
Tim Slattery <Slattery_T_at_bls.gov> wrote:
>Laurenz Albe <invite_at_spam.to.invalid> wrote:
>
>>They have two samples:
>>
>>// SQL-92 syntax
>>conn.prepareCall("{? = call func (?,?)}");
>>
>>// PL/SQL anonymous block
>>conn.prepareCall("begin ? := func(?,?); end;");
>
>I've tried both, I get illegal character from the first and something
>about illegal type from the second. Neither works.
GOT IT!!!
ResultSet result = null; CallableStatement sprocStmt = null; String spName; try { getDBConnection(); /* sets dbConnection */ spName = "{ ? = call getReporterData(?) }"; sprocStmt = dbConnection.prepareCall(spName); sprocStmt.registerOutParameter(1, OracleTypes.CURSOR); sprocStmt.setString(2, key); result = sprocStmt.executeQuery();
I called the executeQuery method of CallableStatement instead of the execute method. executeQuery returns a ResultSet, which contains the good stuff. Calling the execute and getObject methods of CallableStatement, which my examples showed, didn't work. Also, my examples showed "{call ? := call getReporterData(?) }", which didn't work. Remove the colon, move "call" between the equal sign and the function name.
-- Tim Slattery Slattery_T_at_bls.gov http://members.cox.net/slatterytReceived on Wed Aug 20 2008 - 12:51:04 CDT