如何在JAVA中获取Oracle数据库存储过程的结果集?

时间:2015-01-19 05:12:46

标签: java stored-procedures pivot

任何人都可以帮我检索JAVA中Oracle数据库存储过程的结果集。我的存储过程如下:

    create or replace PROCEDURE TESTP 
(
  p_cursor out sys_refcursor

) AS 


    in_clause varchar2(256);
    sel_query varchar2(256);
    n number := 0;

BEGIN


 for  x in (select distinct VENDOR_ID from MF_QUOTATIONS)
    loop    
        if n <> 0 then 
                in_clause := in_clause || ', ';
        end if;
        in_clause := in_clause ||  '''' || x.VENDOR_ID || '''';
        n := 1;    
    end loop;

open p_cursor for select * from (select ITEM_ID, VENDOR_ID, TOTAL from MF_QUOTATIONS) pivot (max(TOTAL) for VENDOR_ID in ('||in_clause||'));




END TESTP;

当我在SQL开发人员处运行时,它显示以下错误

Connecting to the database DBPURCH.
ORA-01722: invalid number
ORA-06512: at "DBPURCH.TESTP", line 17
ORA-06512: at line 5
Process exited.
Disconnecting from the database DBPURCH.

我想在我的JAVA应用程序中获取上述SP的结果集。帮帮我。

0 个答案:

没有答案