0

oracle 开发人员创建了他们的 API - 以 RECORD 作为参数的 PL/SQL 函数。问题是它包含引用记录表的其他记录..

create or replace TYPE QR_OS_REC AS OBJECT (
ICO VARCHAR2(8),
OS05 DATE,
OS09 QR_TAB,
CONSTRUCTOR FUNCTION QR_OS_REC RETURN SELF AS RESULT,
MEMBER FUNCTION validuj RETURN PLS_INTEGER
); 

我需要从 EJB 调用具有此类 IN 参数的函数。我阅读了许多教程,但它们都针对具有标量属性的 bean。QR_TAB类型的OS09怎么办?

谢谢

编辑1:

我尝试使用 StructDescriptor 嵌套 STRUCT,但它在第二次 STRUCT 初始化期间失败(抱歉,与上述示例不同的类型)

StructDescriptor keywordStructDesc = StructDescriptor.createDescriptor("SCHEMA.KEYWORD_REC", conn);
Object[] keywordAttribs = new Object[1];
keywordAttribs[0] = record.getKeyword();

StructDescriptor osobaStructDesc = StructDescriptor.createDescriptor("SCHEMA.PERSON_REC", conn);
Object[] osobaAttribs = new Object[5];
osobaAttribs[0] = record.getName();
osobaAttribs[1] = record.getSurname();
osobaAttribs[2] = record.getAge();
osobaAttribs[3] = record.isVip();
osobaAttribs[4] = new STRUCT(keywordStructDesc, conn, keywordAttribs);
STRUCT struct = new STRUCT(osobaStructDesc, conn, osobaAttribs);

java.sql.SQLException: Inconsistent java and sql object types
    at oracle.sql.StructDescriptor.toOracleArray(StructDescriptor.java:711)
    at oracle.sql.StructDescriptor.toArray(StructDescriptor.java:1298)
    at oracle.sql.STRUCT.<init>(STRUCT.java:167)

编辑2:

我应该传递对象的内容而不是对象本身。

>> keywordAttribs[0] = record.getKeyword();
<< keywordAttribs[0] = record.getKeyword().getValue();

现在可以了。

4

1 回答 1

1

好的,问题解决了。我在博客中用源代码示例对其进行了描述:http ://www.literak.cz/2013/08/working-with-complex-database-types-in-weblogic/

于 2013-08-18T08:47:10.633 回答