从 OUT 参数接收嵌套表的方式取决于表的嵌套方式 考虑简单的数组类型
对象类型
CREATE OR REPLACE
TYPE HR.TNAME
AS
OBJECT( NO1 NUMBER,
NAME VARCHAR2(10)
);
表类型
CREATE OR REPLACE
TYPE HR.ITYPE_CUSTOM
IS TABLE OF tname;
程序
CREATE OR REPLACE PROCEDURE HR.p_schema_level_out(IN1 IN varchar2,p_det OUT itype_custom)
AS
lc_var itype_custom := itype_custom();
BEGIN
lc_var.extend;
lc_var(1) := TNAME(NO1 => 1,NAME => 'TRAIL1');
lc_var(1).no1 := 1;
lc_var(1).name := 'qwe';
p_det:= lc_var;
END;
/
上述返回自定义数组类型的过程可以通过
try {
stmt = con.createStatement();
// -----------------------------------------------------
// Call PL/SQL Procedure
// -----------------------------------------------------
String s1 = "begin p_schema_level_out(?,?); end;";
cstmt = (OracleCallableStatement) con.prepareCall(s1);
cstmt.setString(1, "something");
cstmt.registerOutParameter(2, Types.ARRAY, "ITYPE_CUSTOM");
cstmt.execute();
Object[] data = (Object[]) ((Array) cstmt.getObject(2)).getArray();
for (Object tmp : data) {
STRUCT row = (STRUCT) tmp;
for (Object attribute : row.getAttributes()) {
System.out.println(attribute);
}
cstmt.close();
stmt.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
这可以作为您如何接收表格类型的基础,如果您可以发布嵌套表格类型,我仍然可以帮助您完成