我可以将 String[] 从存储过程转换为“ORA_MINING_VARCHAR2_NT”作为返回值吗?VARRAY 不是一个选项(我有可变数量的元素)
我总是得到一个错误:
ORA-00932: inconsistent datatypes: expected a return value that is an instance of a user defined Java class convertible to an Oracle type got an object that could not be converted
在这段代码中:
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED Parser AS
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;
public class Parser {
public static oracle.sql.ARRAY parseToArray(String str, String delim) throws SQLException {
Connection conn = DriverManager.getConnection("jdbc:default:connection");
ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("ORA_MINING_VARCHAR2_NT", conn);
ARRAY result = new ARRAY(descriptor, conn, str.split(delim));
return result;
}
}
/
CREATE OR REPLACE FUNCTION
PARSETOARRAY (str IN VARCHAR2, delim IN VARCHAR2)
RETURN ORA_MINING_VARCHAR2_NT AS
LANGUAGE JAVA NAME 'Parser.parseToArray (java.lang.String, java.lang.String) return oracle.sql.ARRAY';
/
DECLARE
v_array ORA_MINING_VARCHAR2_NT;
BEGIN
FOR testing IN (SELECT record FROM interfacelog) LOOP
v_array := PARSETOARRAY(testing.record, '|');
-- do smth
END LOOP;
END;
谢谢!
ps 对不起我糟糕的英语