Jasper Reports:java.sql.SQLException: ORA-22905: 无法访问非嵌套 table 项中的行

Jasper Reports:java.sql.SQLException: ORA-22905: cannot access rows from a non-nested table item

我要求相同的输出格式有不同的报告和不同的 tables.So 我实现了 Oracle Piplined 函数和 jasper 报告>报告查询写在下面

Oracle 存储过程

FUNCTION VENDOR_TYPE(REPORT_TYPE IN VARCHAR2) RETURN T_VENDOR_TYPE pipelined

C1 sys_refcursor;

out_rec VENDOR_TYPE := VENDOR_TYPE(0, null, null, null);
BEGIN
IF REPORT_TYPE='1' THEN
OPEN C1 FOR SELECT .....;
ELSIF REPORT_TYPE='2' THEN
OPEN C1 FOR SELECT .....;
END IF;
LOOP 
FETCH C1 INTO out_rec.VENDOR,out_rec.VENDOR_ID;
EXIT WHEN C1%NOTFOUND;
PIPE ROW(out_rec);

END LOOP
CLOSE C1;
RETURN;

END VENDOR_TYPE

我的查询是:

select * from table(VENDOR_TYPE('1')) - was running fine

但我创建了两个参数并将查询更改为

select * from table(VENDOR_TYPE($P{report_no}))

在我执行报告后,它给我如下错误 "java.sql.SQLException: ORA-22905: cannot access rows from a non-nested table item "。你能帮我解决这个问题吗?

你可以试试 CAST:

select * from table(CAST(VENDOR_TYPE($P{report_no}) AS VENDOR_TYPE))