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私の下手な英語でごめんなさい