Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6732275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:37:49+00:00 2026-05-26T10:37:49+00:00

I have no problems to pass numbers and strings back and forth from PL/SQL

  • 0

I have no problems to pass numbers and strings back and forth from PL/SQL to Java, but how do I pass arrays ? I’m calling Java from PL/SQL – not other way round.

Below is an example where get_widgets_as_string works as expected. How do I write a PL/SQL call specification for so19j.get_widgets_as_array() so that I can call it from PL/SQL ?

I have read Publishing Java Classes With Call Specifications where I can see that nested table corresponds to oracle.sql.ARRAY, but I can’t get it working. I’m probably missing some trivial details because I’m not a Java programmer.

create or replace and compile java source named "so19j" as

import java.lang.*;

public class so19j {
    public static String get_widgets_as_string() {
        String widgets = "foo;bar;zoo";
        return widgets;
    }

    public static String[] get_widgets_as_array() {
        String[] widgets = new String[]{"foo", "bar", "zoo"};
        return widgets;
    }
};
/
show errors java source "so19j"

create or replace function get_widgets_as_string return varchar2 as
language java name 'so19j.get_widgets_as_string() return java.lang.String';
/
show errors

declare
  widgets constant varchar2(32767) := get_widgets_as_string;
begin
  dbms_output.put_line('widgets = ' || widgets);
end;
/

/* How to write a call specification for so19j.get_widgets_as_array so that it
can be excercised by the PL/SQL block below ? */

declare
  type widgets_t is table of varchar2(32767);
  widgets constant widgets_t := get_widgets_as_array;
begin
  for i in widgets.first .. widgets.last loop
    dbms_output.put_line('widgets(' || i || ') = ' || widgets(i));
  end loop;
end;
/
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:37:49+00:00Added an answer on May 26, 2026 at 10:37 am
    /* The type has to be SQL type so that it is also visible for Java. */
    create or replace type widgets_t is table of varchar2(32767);
    /
    
    create or replace and compile java source named "so19ja" as
    import java.lang.*;
    public class so19ja {
        public static String[] get_widgets_as_array() {
            String[] widgets = new String[]{"foo", "bar", "zoo"};
            return widgets;
        }
    
        public static java.sql.Array array_wrapper(
            String typeName,
            Object elements
        ) throws java.sql.SQLException {
            oracle.jdbc.OracleDriver ora = new oracle.jdbc.OracleDriver();
            java.sql.Connection conn = ora.defaultConnection();
            oracle.jdbc.OracleConnection oraConn =
                (oracle.jdbc.OracleConnection)conn;
            /* Yeah - typeName have to be UPPERCASE, really. */
            java.sql.Array arr = 
                oraConn.createARRAY(typeName.toUpperCase(), elements);
            return arr;
        }
    
        public static java.sql.Array get_widgets_as_array_wrapped()
        throws java.sql.SQLException {
            return array_wrapper("widgets_t", get_widgets_as_array());
        }
    };
    /
    show errors java source "so19ja"
    
    create or replace function get_widgets_as_array return widgets_t as
    language java name 'so19ja.get_widgets_as_array_wrapped() return java.sql.Array';
    /
    show errors
    
    declare
      widgets constant widgets_t := get_widgets_as_array;
    begin
      for i in widgets.first .. widgets.last loop
        dbms_output.put_line('widgets(' || i || ') = ' || widgets(i));
      end loop;
    end;
    /
    

    Prints:

    widgets(1) = foo
    widgets(2) = bar
    widgets(3) = zoo
    
    PL/SQL procedure successfully completed.
    

    See also: How to create an oracle.sql.ARRAY object?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some messages being passed back from my server through php. The problem
I'm having problems trying to pass an Integer object from a driver class as
I have problem with ActionLink. I'd like to pass to my ActionLink parameter for
I have this little problem, that I cannot figure out which arguments to pass
I have problems with bringing a windows mobile 6 form to the front. I
I have problems binding both a telerik RadGrid and a plain vanilla ASP.NET GridView
I have problems with how I should structure my product listing pages, products pages,
I have problems with dealing with widows within a multicols environment, that is, I
I have problems to get rspec running properly to test validates_inclusion_of my migration looks
I have problems getting some of my views aligned in a relative layout that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.