You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Mike Matrigali <mi...@sbcglobal.net> on 2007/05/26 09:25:47 UTC

are prepareCall and prepareStatement interchangeable when calling derby system procedures?

I see both use of prepareCall and prepareStatement in the tests.
Are both right?  If not is it surprising that the tests pass?


I see code in ImportExportBaseTest like the following:
protected void doExportTable(String schemaName,
                              String tableName,
                              String fileName,
                              String colDel ,
                              String charDel,
                              String codeset) throws SQLException
{
     String expsql =
         "call SYSCS_UTIL.SYSCS_EXPORT_TABLE (? , ? , ? , ?, ? , ?)";
     PreparedStatement ps = prepareStatement(expsql);
     ps.setString(1, schemaName);
     ps.setString(2, tableName);
     ps.setString(3, fileName);
     ps.setString(4, colDel);
     ps.setString(5, charDel);
     ps.setString(6, codeset);
     ps.execute();
     ps.close();
}


And I see code in ImportExportProcedureTest like the following:
cSt = prepareCall(
     "call SYSCS_UTIL.SYSCS_EXPORT_TABLE (null, 'EX_EMP' "
     + ", 'extinout/emp.dat' , null, null, null) ");


Re: are prepareCall and prepareStatement interchangeable when calling derby system procedures?

Posted by Daniel John Debrunner <dj...@apache.org>.
Knut Anders Hatlen wrote:
> Mike Matrigali <mi...@sbcglobal.net> writes:
> 
>> I see both use of prepareCall and prepareStatement in the tests.
>> Are both right?  If not is it surprising that the tests pass?
> 
> I think you only need prepareCall if the procedure has out parameters,
> since CallableStatement has methods to retrieve parameter values whereas
> PreparedStatement doesn't. If it doesn't have out parameters, you can
> use either of them.

That's correct, I seem to recall some discussion that maybe at some 
point JDBC specification may require use of CallableStatement for a 
procedure call, but that's not true at the moment.

Dan.

Re: are prepareCall and prepareStatement interchangeable when calling derby system procedures?

Posted by Knut Anders Hatlen <Kn...@Sun.COM>.
Mike Matrigali <mi...@sbcglobal.net> writes:

> I see both use of prepareCall and prepareStatement in the tests.
> Are both right?  If not is it surprising that the tests pass?

I think you only need prepareCall if the procedure has out parameters,
since CallableStatement has methods to retrieve parameter values whereas
PreparedStatement doesn't. If it doesn't have out parameters, you can
use either of them.

-- 
Knut Anders