I have no problem passing numbers and strings from PL / SQL to Java, but how do I pass arrays? I call Java from PL / SQL - not the other way around.
The following is an example where get_widgets_as_string works as expected. How to write a PL / SQL call specification for so19j.get_widgets_as_array() so that I can call it from PL / SQL?
I read the publication of Java classes with call specifications , where I see that the nested table matches oracle.sql.ARRAY , but I canβt get it working. I probably missed 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; / 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; /
source share