Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: 10046/10079 Tracing understanding - SOLVED

Re: 10046/10079 Tracing understanding - SOLVED

From: Edgar Chupit <chupit_at_gmail.com>
Date: Thu, 4 Aug 2005 21:26:48 +0300
Message-ID: <a8f0771c05080411267c90f6a1@mail.gmail.com>


Jared,

But now think about this from the driver perspective, when you call this procedure from java you simply define type of the second parameter and that it is output parameter, without specifying expected length of the data.

I.e. you call stmt.registerOutParameter(3,Types.VARCHAR);

Oracle JDBC driver has no idea about what will be the maximal length of the output parameter, so it reserves space for a maximal possible char string (32k).

When you call this procedure from pl/sql, pl/sql engine knows maximal length of the string that you expect, because you have defined length for the variable that will hold out parameter (v1 and v2).

As for original problem, you can set maximal expected length of the parameter, if you will use OracleCallableStatement instead of CallableStatement and use this function:

void registerOutParameter(int paramIndex, int sqlType, int scale, int maxLength)

          Special Oracle version of registerOutParameter for registering CHAR, VARCHAR, LONG, RAW and LONG RAW columns.

http://download-east.oracle.com/otn_hosted_doc/jdeveloper/904preview/jdbc-javadoc/oracle/jdbc/OracleCallableStatement.html

For example:

OracleCallableStatement stmt =
(OracleCallableStatement)conn.prepareCall ("begin ? := mychar(?,?,?); end;");

stmt.registerOutParameter(1,Types.CHAR);
stmt.setString(2,"this is a test");
stmt.registerOutParameter(3,Types.CHAR, 0, 50);
stmt.registerOutParameter(4,Types.CHAR, 0, 50);

Output:
JDBC driver version is 10.1.0.3.0
Return length is: 50
Trimmed string is: this is a test
Trimmed string length is: 14

On 8/4/05, Jared Still <jkstill_at_gmail.com> wrote:

> Yes, but even so, PL/SQL does not pad the CHAR input parameter out to 32k.

> It will be the length of the string without padding.
>
-- 
  Edgar
     callto://edgar.chupit
--
http://www.freelists.org/webpage/oracle-l
Received on Thu Aug 04 2005 - 13:30:03 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US