4

Is it possible to create a java representation of a package-level oracle associative array. For example, given the following:

CREATE OR REPLACE PACKAGE MyPackage AS
    TYPE t_numbers IS TABLE OF NUMBER INDEX BY PLS_INTEGER;

I find I cannot write the following java:

ArrayDescriptor descriptor =
    ArrayDescriptor.createDescriptor("MyPackage.t_numbers", connection);

(throws a SQLException "Invalid name pattern").

What is the correct syntax for an ArrayDescriptor referencing a package-level associative array? Does such a thing even exist?

Andy
  • 3,596
  • 8
  • 34
  • 33

2 Answers2

6

See http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3696816290928 and especially http://download.oracle.com/docs/cd/B10501_01/java.920/a96654/oci_func.htm#1017512 .

Xavi López
  • 27,550
  • 11
  • 97
  • 161
tuinstoel
  • 7,248
  • 27
  • 27
  • 1
    Second link was spot on, thanks. To summarize - don't use ArrayDescriptor when referencing package-level associative arrays. Cast the callable statement to an OracleCallableStatement and use setPlsqlIndexTable. Doesn't support records, though... – Andy Jan 20 '09 at 11:00
  • @Andy many thanks for your comment. It helped me solve the same issue you had, even with link rot affecting the answer's second link. – Xavi López Jul 09 '12 at 15:21
1

You can also use OracleConnection.createOracleArray()

Note that arrayTypeName should be the table of type.

Also, you may find my my answer on getArray() and writeArray() useful.

Arlo
  • 1,331
  • 2
  • 15
  • 26