Re: bind variables from java code
Date: 23 May 2003 10:54:17 -0700
Message-ID: <cf59f633.0305230954.3595c7c4_at_posting.google.com>
hayt_at_inwind.it (hayt) wrote in message news:<11f54ca0.0305230126.1a9caf51_at_posting.google.com>...
> Hi to all.
> I want to make you a qustion:
> I know two way to call a stored procedure from a piece of java code,
> with very few differences.
> Both of them use a CallableStatement, but the first bind the input
> parameters directly in the String passed to the prepareCall method,
> while the latter provides to the prepareCall method only quotation
> mark as stored procedure parameters and the binds the input parameters
> with the set methods of the CallableStatement. An exemple will clarify
> the two approaches:
>
> FIRST approach
> .....
> CallableStatement cstmt;
> String storedProcCall = "{ CALL SC_FILL_PRESENCE(?, ?, ?, ?) };
> cstmt = dbConn.prepareCall(storedProcCall);
> // Binding input varialbes
> cstmt.setString(1, v_udptype);
> cstmt.setString(2, v_ip);
> //Registering SP out parameters
> cstmt.registerOutParameter(3, java.sql.Types.INTEGER);
> cstmt.registerOutParameter(4, java.sql.Types.VARCHAR);
> .....
>
> SECOND approach
> .....
> CallableStatement cstmt;
> //input parameters already binded inside the String
> String storedProcCall = "{ CALL SC_FILL_PRESENCE(v_udptype, v_ip, ?,
> ?) };
> cstmt = dbConn.prepareCall(storedProcCall);
> //Registering SP out parameters
> cstmt.registerOutParameter(1, java.sql.Types.INTEGER);
> cstmt.registerOutParameter(2, java.sql.Types.VARCHAR);
> .....
>
> What's the differences on Oracle side? It opens more cursors parsing
> the String with already the input parameters in there? And if it's
> true, why?
>
> Thanks in advance
Received on Fri May 23 2003 - 19:54:17 CEST