将对象数组从PLSQL传递到Java函数时出错

将对象数组从PLSQL传递到Java函数时出错,java,oracle,plsql,java-stored-procedures,varray,Java,Oracle,Plsql,Java Stored Procedures,Varray,我有一个类型abc\u type和一个类型abc\u table的数组。 我试图将对象数组传递给java函数 create type abc_type authid definer as object ( file_name varchar2(5000), file_size number, file_paths varchar2(4000) ); create type abc_table as table of abc_type; create

我有一个类型abc\u type和一个类型abc\u table的数组。 我试图将对象数组传递给java函数

create type abc_type authid definer as object
  ( file_name    varchar2(5000),
    file_size    number,
    file_paths   varchar2(4000)
    );
create type abc_table as table of abc_type;

create or replace and compile java source named "Hello" as
public class Hello
{
  public static String world(String str,Array str2)
  {
    return "Hello world - "+ str;
  }
}
/

CREATE OR REPLACE FUNCTION helloworld (
str_in in varchar2,
str2_in in abc_table
)
RETURN VARCHAR2 AS
LANGUAGE JAVA NAME 'Hello.world (java.lang.String,oracle.sql.Array) return java.lang.String';
/

declare 
str varchar2(200):='def';
zipfiles abc_table:=abc_table();
begin
zipfiles.extend(1);
zipfiles(1) := abc_type('aaa',22,'bbb');
dbms_output.put_line('test:'||helloworld('abc',zipfiles));
end;
/
一切都编译得很好,但我发现错误ORA-29541:class。无法解决Hello问题。 如果我用String/Varchar2替换数组类型,效果很好


标题您应该使用导入oracle.sql。数组

create or replace  and COMPILE java source named "Hello" as
import oracle.sql.ARRAY;
public class Hello
{
  public static String world(String str,ARRAY str2)
  {
    return "Hello world - "+ str;
  }
}
我认为不能从PL/SQL将复合类型(嵌套表)传递给java函数。在本例中,您传递的是复合数据类型的abc_类型。据我所知,只能传递一维或单一数据类型的嵌套表或数组。我不太确定,请考虑一下我的想法。

请检查以下链接以获取相同信息

您应该使用导入oracle.sql。数组

create or replace  and COMPILE java source named "Hello" as
import oracle.sql.ARRAY;
public class Hello
{
  public static String world(String str,ARRAY str2)
  {
    return "Hello world - "+ str;
  }
}
我认为不能从PL/SQL将复合类型(嵌套表)传递给java函数。在本例中,您传递的是复合数据类型的abc_类型。据我所知,只能传递一维或单一数据类型的嵌套表或数组。我不太确定,请考虑一下我的想法。

请检查以下链接以获取相同信息
修复了以下更改

添加了导入语句

import oracle.sql.*; // I had added this earlier, but this alone didn't fix the issue.
import java.sql.*;

//With the above, I was able to pass the object, but I was not able to reference the object.
添加了异常处理

throws IOException,java.sql.SQLException to the function.
最终代码(还有一些其他更改)


修复了以下更改

添加了导入语句

import oracle.sql.*; // I had added this earlier, but this alone didn't fix the issue.
import java.sql.*;

//With the above, I was able to pass the object, but I was not able to reference the object.
添加了异常处理

throws IOException,java.sql.SQLException to the function.
最终代码(还有一些其他更改)


尝试添加
导入oracle.sql.Array在Java源代码的开头。尝试添加
import oracle.sql.Array在Java源代码的开头。谢谢!这个链接非常有用。我能够通过复合类型。你是如何通过复合类型的?你可以看看我答案中的“最终代码”。我要通过一个复合类型。谢谢!这个链接非常有用。我能够通过复合类型。你是如何通过复合类型的?你可以看看我答案中的“最终代码”。我正在通过一个复合类型。