4

When I try to throw an Array of strings to oracle stored procedure as:

String arrStr[] ={"val1","val2","val3"};
ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("STR_ARRAY", connection );

oracle.sql.ARRAY oracleArray = new oracle.sql.ARRAY(descriptor, connection, arrStr);

oracleArray holds null data , oracleArray.datumArray = {???,???,???}

5
  • What is the SQL definition of STR_ARRAY? Here's a working example, can you reproduce this example on your system? Commented Feb 21, 2013 at 9:28
  • here is the script of creating type in database: CREATE TYPE str_array AS TABLE OF VARCHAR2 (40) Commented Feb 21, 2013 at 9:32
  • How are you determining that it holds null data - with oracleArray.dump(), looking at the Datum elements from oracleArray.getOracleArray()... or something else? (Since I don't think you can access datumArray directly). Or are the values null on the Oracle side when you try to use the passed array in your procedure - in which case you might need to show that call as well? Commented Feb 21, 2013 at 10:49
  • I determine that it holds null data by watching 'oracleArray' in debugging mode. Commented Feb 21, 2013 at 11:23
  • I'm having same issue - using oracle 9i as well as 10g and all available jdbc drivers - result is the same. oracle.sql.ARRAY is empty when it is created in java, INSERT in the procedure will therefore create only null vvalues - I'm trying to find solution, but no luck so far :( did you oslve the problem? Commented Sep 13, 2013 at 12:00

3 Answers 3

10

In my case (see my comment above), it was caused by encoding problem, however - without any exception or debug information. Including orai18n.jar to the project libraries solved this... it is really sad, there is no exception or something that would indicate how to solve the problem

Sign up to request clarification or add additional context in comments.

2 Comments

Glad to hear you figured this out, and thanks for posting the solution. Oracle issues can be a bit difficult to figure out, and even it does give you an error message, it isn't always accurate or helpful. +1
Awwww, man, that's so cool! This is solution for me too! Can you explain, why we need orai18n.jar in classpath? How it affects our project?
1

After hours I have founded the cause, the real problem is the NLS_CHARACTERSET of your database work with a encoding that is not supported by your client, to jdbc support others NLS_LANG is necessary add orai18n.jar in classpath. See your database settings with this sql:

SELECT * FROM NLS_DATABASE_PARAMETERS

Comments

0

Probably your STR_ARRAY is defined in this way:

create or replace type STR_ARRAY is table of VARCHAR2(20);

As Tomas said the problem is encoding. My solution - use NVARCHAR2 instead.

create or replace type STR_ARRAY is table of NVARCHAR2(20);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.