This discussion is archived
0 Replies Latest reply: May 23, 2012 4:53 AM by 939190 RSS

array.toString() returns toString on first element when called via PL/SQL

939190 Newbie
Currently Being Moderated
Hi all,

we're facing the following issue:

We have a PL/SQL function calling a Java function:
create or replace and compile java source named CharArrayToString as
  public class CharArrayToString {
    public static String arrayToString(oracle.sql.CHAR[] input) {
      return input.toString();
    public static String charToString(oracle.sql.CHAR input) {
      oracle.sql.CHAR[] array = new oracle.sql.CHAR[] { input };
      return array.toString();

create or replace function CharArrayToString (s1 VARCHAR2) return VARCHAR2
  language java
  name 'CharArrayToString.arrayToString(oracle.sql.CHAR[]) return java.lang.String';

create or replace function CharToString (input varchar2) return varchar2 
  language java
  name 'CharArrayToString.charToString(oracle.sql.CHAR) return java.lang.String';
When calling arrayToString via
select CharArrayToString('test') from dual;
the result is 'test'.

But when calling .arrayToString via another Java method call as in
select CharToString('test') from dual;
the result is '[Loracle.sql.CHAR;@4b374d3c'.

I expected the second result in both cases.
What magic is PL/SQL or OJVM doing that toString() on an array returns the result of toString() on the first element of the array?
Can anybody provide pointers to documentation/spec/discussion/bug report?



  • Correct Answers - 10 points
  • Helpful Answers - 5 points