Call procedure with return cursor

Dear All,
there is a cast with my job. i have procedure like below:
CREATE OR REPLACE PROCEDURE ISISALL.P_TEST (PARAM1 IN VARCHAR2,RETURN_TABLE OUT SYS_REFCURSOR) IS
BEGIN
OPEN RETURN_TABLE FOR
SELECT FIELD2,FIELD3 FROM MYTABLE
WHERE FIELD1=PARAM1;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
RAISE;
END P_TEST;
my question, How to call the procedure ? i want insert table with source from the procedure (P_TEST)..

>
How to call the procedure ? i want insert table with source from the procedure (P_TEST)..
>
This code sample that you can test in the SCOTT schema should give you enough information
CREATE OR REPLACE TYPE SCOTT.local_type IS OBJECT (
    empno   NUMBER(4),
    ename   VARCHAR2(10));
CREATE OR REPLACE TYPE SCOTT.local_tab_type IS TABLE OF local_type;
CREATE OR REPLACE PACKAGE SCOTT.test_refcursor_pkg
AS
    TYPE my_ref_cursor IS REF CURSOR;
     -- add more cursors as OUT parameters
     PROCEDURE   test_proc(p_ref_cur_out OUT test_refcursor_pkg.my_ref_cursor);
END test_refcursor_pkg;
CREATE OR REPLACE PACKAGE BODY SCOTT.test_refcursor_pkg
AS
     PROCEDURE  test_proc(p_ref_cur_out OUT test_refcursor_pkg.my_ref_cursor)
     AS
        l_recs local_tab_type;
     BEGIN
         -- Get the records to modify individually.
         SELECT local_type(empno, ename) BULK COLLECT INTO l_recs
         FROM EMP;
         -- Perform some complex calculation for each row.
         FOR i IN l_recs.FIRST .. l_recs.LAST
         LOOP
             DBMS_OUTPUT.PUT_LINE(l_recs(i).ename);
         END LOOP;
         -- Put the modified records back into the ref cursor for output.  
         OPEN p_ref_cur_out FOR
         SELECT * from TABLE(l_recs);      
         -- open more ref cursors here before returning
     END test_proc;
END;
SET SERVEROUTPUT ON SIZE 1000000
DECLARE
  l_cursor  test_refcursor_pkg.my_ref_cursor;
  l_ename   emp.ename%TYPE;
  l_empno   emp.empno%TYPE;
BEGIN
  test_refcursor_pkg.test_proc (l_cursor);
  LOOP
    FETCH l_cursor
    INTO  l_empno, l_ename;
    EXIT WHEN l_cursor%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE(l_ename || ' | ' || l_empno);
  END LOOP;
  CLOSE l_cursor;
END;
/Are you sure you wouldn't be better off using a PIPELINED function instead? Then you can just select from it as if it were a table and do whatever you want with the data
-- type to match emp record
create or replace type emp_scalar_type as object
  (EMPNO NUMBER(4) ,
   ENAME VARCHAR2(10),
   JOB VARCHAR2(9),
   MGR NUMBER(4),
   HIREDATE DATE,
   SAL NUMBER(7, 2),
   COMM NUMBER(7, 2),
   DEPTNO NUMBER(2)
-- table of emp records
create or replace type emp_table_type as table of emp_scalar_type
-- pipelined function
create or replace function get_emp( p_deptno in number )
  return emp_table_type
  PIPELINED
  as
   TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
    emp_cv EmpCurTyp;
    l_rec  emp%rowtype;
  begin
    open emp_cv for select * from emp where deptno = p_deptno;
    loop
      fetch emp_cv into l_rec;
      exit when (emp_cv%notfound);
      pipe row( emp_scalar_type( l_rec.empno, LOWER(l_rec.ename),
          l_rec.job, l_rec.mgr, l_rec.hiredate, l_rec.sal, l_rec.comm, l_rec.deptno ) );
    end loop;
    return;
  end;
select * from table(get_emp(20))

Similar Messages

  • About:call procedure with returned resultset

    how can i do for that?
    thanks!

    CREATE OR REPLACE FUNCTION selectAllEmployments
    RETURN SYS_REFCURSOR
    AS
    st_cursor SYS_REFCURSOR;
    BEGIN
    OPEN st_cursor FOR
    SELECT EMPLOYEE, EMPLOYER,
    STARTDATE, ENDDATE,
    REGIONCODE, EID, VALUE, CURRENCY
    FROM EMPLOYMENT;
    RETURN st_cursor;
    END;
    To use this query in Hibernate you need to map it via a named query.
    <sql-query name="selectAllEmployees_SP" callable="true">
    <return alias="emp" class="Employment">
    <return-property name="employee" column="EMPLOYEE"/>
    <return-property name="employer" column="EMPLOYER"/>
    <return-property name="startDate" column="STARTDATE"/>
    <return-property name="endDate" column="ENDDATE"/>
    <return-property name="regionCode" column="REGIONCODE"/>
    <return-property name="id" column="EID"/>
    <return-property name="salary">
    <return-column name="VALUE"/>
    <return-column name="CURRENCY"/>
    </return-property>
    </return>
    { ? = call selectAllEmployments() }
    </sql-query>

  • Call procedure with named parameters

    Call procedure with positional parameters works, but with named parameters gives an ORA-907.
    This post seems similar: Re: Error with report - pkg and bind var
    Run as a script:
    set echo on
    call dbms_stats.delete_table_stats ('ZZZMIG', 'CHAINED_ROWS', cascade_columns=>true, no_invalidate=>false);
    call dbms_stats.delete_table_stats ('ZZZMIG', 'CHAINED_ROWS');
    begin dbms_stats.delete_table_stats ('ZZZMIG', 'CHAINED_ROWS', cascade_columns=>true, no_invalidate=>false); end;
    gives:
    set echo on
    call dbms_stats.delete_table_stats ('ZZZMIG', 'CHAINED_ROWS', cascade_columns=>true, no_invalidate=>false)
    Error starting at line 2 in command:
    call dbms_stats.delete_table_stats ('ZZZMIG', 'CHAINED_ROWS', cascade_columns=>true, no_invalidate=>false)
    Error report:
    SQL Error: ORA-00907: missing right parenthesis
    00907. 00000 - "missing right parenthesis"
    *Cause:
    *Action:
    call dbms_stats.delete_table_stats ('ZZZMIG', 'CHAINED_ROWS')
    call dbms_stats.delete_table_stats succeeded.
    begin dbms_stats.delete_table_stats ('ZZZMIG', 'CHAINED_ROWS', cascade_columns=>true, no_invalidate=>false); end;
    anonymous block completed
    I like the idea of using call, because the procedure name appears in the feedback - useful in longer scripts.
    I'm using SQL Developer Version 1.5.1 Build MAIN-5440
    on Windows XP SP3
    with database EE 10.2.0.3

    CALL is a SQL command which executes a routine
    (procedure/function)
    http://download-uk.oracle.com/docs/cd/B19306_01/server
    .102/b14200/statements_4008.htm
    whereas EXECUTE is a SQL*Plus command which executes
    a single PL/SQL statement
    http://download-uk.oracle.com/docs/cd/B19306_01/server
    .102/b14357/ch12022.htm#i2697931
    Message was edited by:
    Jens PetersenThank you very much, esp. for the links!

  • Executing a Function in a Stored Procedure to Return Cursor

    I have a function named f_CPCRBPBR who base on the following types
    CREATE Or Replace TYPE RecType_fAC
    AS OBJECT ( << Structure >>);
    CREATE Or Replace TYPE Tbl_fAC
    AS TABLE OF RecType_fAC;
    Create Or Replace
    Function f_CPCRBPBR (
    i_Vtp Varchar2,
    i_Mnth Varchar2,
    i_Location Varchar2,
    i_vno integer,
    i_vnoTo integer,
    St_Date Varchar2,
    En_Date Varchar2
    Return TBL_fAC
    Pipelined
    Is
    RetVal RecType_fAC;
    Begin
    Now the problem is that I want to Call this Function from Within a Procedure who would return the Recordset..
    can any body suggest..
    I want to use the Record Type used for the Said Function..
    Please Help..

    This is Excellent .. This is great.. actually this is marvellous.. can u please defined a bit about Sys_RefCursor...
    this is an excellent thing..
    I finally Concluded the procedure as follows who not only called but also returned the cursor..
    Create Or Replace Procedure p_CPCRBPBR (TstCrsr In Out Sys_RefCursor,
    i_Vtp Varchar2,
    i_Mnth Varchar2,
    i_Location Varchar2,
    i_vno integer,
    i_vnoTo integer,
    St_Date Varchar2,
    En_Date Varchar2
    as
    Begin
    Open TstCrsr FOr
    Select * from Table(f_CPCRBPBR (i_VTP, i_Mnth, i_Location, i_VNo, i_VNoTo, '', ''));
    End;
    Can u please help me what will be the exact syntax to call / test this procedure in SQL Developer..
    as if i try this procedure as
    Execute p_CPCRBPBR null, 'CP', '01', 'L', 1, 1, null, null
    it give error Invalid SQL Statement ..
    2. Can u please check this code and refer me a solution for Calling this function
    create or replace function NewTest (iEN Integer)
    return sys_refcursor
    as
    rc sys_refcursor;
    begin
    open rc for select * from Scott.Emp Where EmpNo=iEN;
    return rc;
    end;
    This function easily created but when i tried to execute this with the following statement
    Select * from Table(NewTest (7369))
    It gives error
    Cannot Access Rows From a Non-Nested Table Item..
    .. Thanx for ur patience...

  • How to call procedure with Object types in java

    Hi,
    We have procedure declaration as follows
    ===============
    TYPE TEST_TYPE AS OBJECT (NAME VARCHAR2(10));
    TYPE TESTTYPE1 AS object (student1 TESTTYPE,student2 TESTTYPE,student3 TESTTYPE);
    TYPE rect AS OBJECT
    -- The type has 3 attributes.
    length NUMBER,
    width NUMBER,
    area NUMBER,
    -- Define a constructor that has only 2 parameters.
    CONSTRUCTOR FUNCTION rect(length NUMBER, width NUMBER)
    RETURN SELF AS RESULT
    PROCEDURE G(obj1 in TESTTYPE1,obj2 out rect) as
    n1 testtype;
    n2 testtype;
    n3 testtype;
    n4 testtype;
    begin
    obj2 := NEW rect(10,20,200);
    n1 := obj1.student1;
    n2 := obj1.student2;
    n3 := obj1.student3;
    obj2.length :=20;
    end;
    =====================================================
    I am not able to call the procedure in java code as I cannot figure out which out parameter type will it be registered using registeroutparameter. using cursor or struct type fails.
    please let me know how I can pass values from stored procedure with objects to java.

    I'm not sure what you're trying to accomplish with your procedure, but in general, this is an example of how you could use oracle.sql.STRUCT.
    First, prepare your java.sql.CallableStatement using java.sql.CallableStatement cStmt = java.sql.Connection.prepareCall({ call G(?, ?) });
    Note that you don't have to use the OracleCallableStatement. The java.sql.CallableStatement will work just fine.
    For the IN parameter, you need to create three TEST_TYPE objects. Then you need to create one TESTTYPE1 object.
    These will all be instances of oracle.sql.STRUCT.
    To create a oracle.sql.STRUCT object you need a descriptor and a set of attributes. For example, to create a TEST_TYPE object you would do the following
    1. StructDescriptor sd = StructDescriptor.createDescriptor("TEST_TYPE", java.sql.Connection).
    2. Add a VARCHAR2 attribute to an array of attributes (e.g. Object[] attributes = new Object[]{"Student Name"})
    3. oracle.sql.STRUCT struct = new oracle.sql.STRUCT(sd, java.sql.Connection, attributes)
    Then do something similar to create the TESTTYPE1 object, except that the attribute array will contain three instances of TEST_TYPE struct objects.
    To bind the IN parameter you need to use the java.sql.CallableStatement.setObject(1, <Instance of TESTTYPE1 object>).
    To register the OUT parameter, you need to call java.sql.CallableStatement.registerOutParameter(2, oracle.jdbc.OracleTypes.STRUCT, "RECT").
    Then, execute your procedure using cStmt.execute();
    Retrieve your OUT parameter using oracle.sql.STRUCT struct = (oracle.sql.STRUCT)cStmt.getObject(2).
    Once you've done that, to get the values of the attributes of all of your STRUCT objects, you need their descriptors and their metadata.

  • SSRS 2008 Using Stored Procedure with SysRef Cursor Oracle

    Hi,
    I am new to SSRS.
    I have a ssrs procedure which runs to Return Result of Select Query. ( In form of SYS REF Cursor in Oracle ).
    When I am trying to see the Value in Test Window. It is showing Output. But when I m Running the Report in the environment it is giving me error.
    Please help me if there is a better way of handling it.
    As I read in some forum as SSRS has issue handling SYS Ref Cursor...
    Thanks
    Priyank
    Thanks Priyank Piyush

    Hi Priyank,
    According to your description, you are use a Stored Procedure from SysRef Cursor Oracle as the report dataset. The query works well in Dataset Query Designer, while an error occurs when you render the report.
    As per my understanding, the problem is that there are something wrong with the report design. Please double-check the design of the report. In order to trouble shoot the problem more efficiently, could you please post the detail error message? Then we can
    make further analysis.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Call procedure with MS SQL from linked Oracle server

    I have a procedure on a remote server that I can call from SQL*PLUS
    set serveroutput on
    declare rez varchar2(99); msg varchar2(99); begin radar.test('AL25',rez,msg); dbms_output.put_line('Rez='||rez);
    dbms_output.put_line('Msg='||msg);
    end;
    it gives me the neccessary result.
    But I need to call the same procedure with MS SQL from a linked Oracle server, I'm trying to do it through openquery for a while, but no success yet.
    Can someone tell me what is the right syntax for that query in OPENQUERY?

    Have you tried configuring Oracle Heterogenous Services/ Transparent Gateway? This would let you link Oracle to SQL Server via a database link which should solve your problem.
    Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com

  • Procedure with Return statement

    Hi,
    Below is my code. Am trying to return a value without a out parameter in the procedure. Is out parameter is mandatory to return a value in a procedure. Please help.
    CREATE OR REPLACE
    PROCEDURE P123(
        PID NUMBER)
    AS
      VCOUNT NUMBER;
    BEGIN
      SELECT COUNT(*) INTO VCOUNT FROM EMP WHERE EMPNO=PID;
      IF (VCOUNT=1) THEN
        RETURN 1;
      ELSE
        RETURN 0;
      END IF;
    END;Thanks

    Hi,
    When a procedure encounters a RETURN statement, it Returns the control, back to the calling program. In the below example, P1 is calling P2. When P2 encounters a RETURN statement, control is passed back to P1 procedure and "Out of p2 procedure" message is printed as per below example.
    Note: No further execution happens in P2 procedure when return is encountered.
    create or replace procedure P1
    as
    Begin
    p2;
    dbms_output.put_line('Out of the p2 procudure");
    end;
    create or replace procedure P2
    as
    begin
    dbms_output.put_line('calculation 1");.......
    return;
    dbms_output.put_line('calculation 2");
    end;
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Problem calling Procedure with parameter from Dynamic Page

    I received an error saying the Page not found
    here's how to reproduce the error.
    1. Create procedure in portal30 schema.
    Create or Replace PROCEDURE PORTAL30.ADD_TWO_VALUES
    v_one IN NUMBER,
    v_two IN NUMBER,
    v_result OUT NUMBER)
    as
    begin
    v_result :=v_one+v_two;
    end;
    2. Create Dynamic Page with following code
    <ORACLE>DECLARE
    v_total NUMBER;
    BEGIN
    ADD_TWO_VALUES(:v_one,:v_two, v_total);
    htp.p('The total is => ');
    htp.p('<input type="TEXT" VALUE='||v_total||'>');
    htp.para;
    htp.anchor('http://<machine.domain:port#>/pls/portal30/PORTAL30.DYN_
    ADD_TWO_VALUES.show_parms', 'Re-Execute Procedure');
    END;</ORACLE>
    3. I clicked on Customize Link and entered 2 numbers as values for v_one and v_two.
    4. Got "The page cannot be found" error in I.E. or "The requested URL /pls/portal30/PORTAL30.DYN_SAMPLE_ADD.show was not found on this server." on Netscape
    However when I subsitute "ADD_TWO_VALUES(:v_one,:v_two, v_total);" in the dynamic page for "ADD_TWO_VALUES(3,2, v_total);", it runs just fine.
    What's wrong here? Can I not use a parameter from a dynamic page and call a procedure with it? Help is needed urgently and will be greatly appreciated.
    -Ahsun

    Hi,
    I tried with your code with few changes ,please try with them.
    Create or Replace PROCEDURE <myschema>.ADD_TWO_VALUES
    v_one IN NUMBER,
    v_two IN NUMBER,
    v_result OUT NUMBER)
    as
    begin
    v_result :=v_one+v_two;
    end;
    I created the procedure in <mySchema> and granted that to <application_schema> and made some changes
    <ORACLE>
    DECLARE
    v_total NUMBER;
    BEGIN
    <procedure_schema>.ADD_TWO_VALUES(:v_one,:v_two, v_total);
    htp.p('The total is => ');
    htp.p('<input type="TEXT" VALUE='||v_total||'>');
    htp.para;
    htp.anchor('http://<your_host>/pls/<portal_schema>/<application_schema>.DYN_FOR_OTN.SHOW_PARMS', 'Re-Execute Procedure');
    END;
    </ORACLE>
    Hope this helps.
    rahul

  • Testing procedure that returns cursor.

    Please
    How Can I test a procedure that returns a cursor? I need to execute it on sqlplus.
    Thank you very much

    Hi,
    Example using HR schema:
    The proc_cursor procedure returns a cursor and the block below test it
    SET SERVEROUTPUT ON
    DECLARE
        TYPE t_ref_cur IS REF CURSOR;
        v_cursor   t_ref_cur;
        v_employee employees%ROWTYPE;
        PROCEDURE proc_cursor(p_cursor OUT t_ref_cur) IS
            v_sql VARCHAR2(4000);
        BEGIN
            v_sql := 'SELECT * FROM EMPLOYEES';
            OPEN p_cursor FOR v_sql;
        END;
    BEGIN
        proc_cursor(p_cursor => v_cursor);
        LOOP
            FETCH v_cursor
                INTO v_employee;
            EXIT WHEN v_cursor%NOTFOUND;
            dbms_output.put_line(v_employee.employee_id);
        END LOOP;
        CLOSE v_cursor;
    END;
    /Regards,

  • 64bit OraOLEDB failed when calling stored procedure with Ref Cursor

    Hi everyone,
    I used the ADO VB sample provided with the Oracle 10g provider installation.
    But I compiled it in 64bit Visual Studio 2005 and ran on Windows 2003 x64 server.
    The function call "cmd.Execute" when it is trying to call a stored procedure which has an Out Ref Cursor parameter. The exception is
    "PLS-00306: wrong number or types arguments in call"
    I already set the property "PLSQLRSet" to true. But it doesn't help.
    The same code works if I compiled in 32 bit.
    It also works if the stored procedure does not have Ref Cursor parameter.
    I am guessing this is a bug in the 64bit Oracle provider. Anyone can confirm this please? or am I missing anything?
    Wilson

    It appears to work with 11.1.0.6.20 OLEDB provider but only for ExecuteNonQuery, I'm not able to work with Fill, and yes... in x86 works perfectly, but in x64 we are still having the ORA-06550 and PLS-00306 error.
    Our Connection string is as follows:
    "Provider=OraOLEDB.Oracle.1;OLEDB.NET=true;Password=xxxxx;Persist Security Info=True;User ID=exxxxx;Data Source=ECOR; PLSQLRSet=True"
    We are not using ODP.NET.
    Can you confirm that Fill method works with such update?

  • Ora-01001 in procedures with ref cursor parameter after upgrade to 11.1.0.7

    Hi,
    after upgrading from 11.1.0.6.0 to 11.1.0.7.0, I get ora-01001 in procedure calls which have a ref cursor as an out parameter.
    Even a new 11.1.0.7 instance throws this error. My OS is Linux SLES10SP2.
    Please see atched sample code:
    CREATE OR REPLACE PACKAGE test1_pck
    IS
    PROCEDURE run1; -- OK on 11.1.0.6; fails on 11.1.0.7
    PROCEDURE run2; -- OK on 11.1.0.6; OK on 11.1.0.7
    END test1_pck;
    CREATE OR REPLACE PACKAGE BODY test1_pck
    IS
    TYPE t_rec IS RECORD(col dual.dummy%TYPE);
    TYPE t_cur IS REF CURSOR RETURN t_rec;
    PROCEDURE foo1(p_cur OUT t_cur)
    IS
    v_sql VARCHAR2(255) := 'BEGIN OPEN :1 FOR SELECT dummy FROM dual; END;';
    BEGIN
    EXECUTE IMMEDIATE v_sql USING p_cur;
    END foo1;
    PROCEDURE foo2
    IS
    v_sql VARCHAR2(255) := 'BEGIN OPEN :1 FOR SELECT dummy FROM dual; END;';
    v_cur t_cur;
    v_rec t_rec;
    BEGIN
    EXECUTE IMMEDIATE v_sql USING v_cur;
    LOOP
    FETCH v_cur INTO v_rec;
    EXIT WHEN v_cur%NOTFOUND;
    CASE v_rec.col
    WHEN 'X' THEN dbms_output.put_line('success');
    ELSE dbms_output.put_line('error');
    END CASE;
    END LOOP;
    END foo2;
    PROCEDURE run1
    IS
    v_cur t_cur;
    v_rec t_rec;
    BEGIN
    foo1(v_cur);
    LOOP
    FETCH v_cur INTO v_rec;
    EXIT WHEN v_cur%NOTFOUND;
    CASE v_rec.col
    WHEN 'X' THEN dbms_output.put_line('success');
    ELSE dbms_output.put_line('error');
    END CASE;
    END LOOP;
    END run1;
    PROCEDURE run2
    IS
    BEGIN
    foo2;
    END run2;
    END test1_pck;
    Thanks for any hints.
    Regards Frank

    Hi Max,
    the referenced thread discusses a .Net problem. A lot of layers are involved their. My problem is a very basic problem. You get this error even if you run the test in a sql session on the server.
    It would be a great help for me
    a) if someone could test this package on a 11.1.0.7 database
    b) if someone could test this package on a 11.2 database (is it fixed in Release2?)
    c) if someone could give me hints how I could modify the procedure to make it usable for 11.1.0.7
    (I already tried a lot e.g. EXECUTE IMMEDIATE v_sql USING OUT p_cur;
    Thank you
    Frank

  • Call procedure with Spring and strange invalid index error.

    Hi I call a procedure, from java in this way:
    FlussiGiornalieriStoredProcedure proc = new FlussiGiornalieriStoredProcedure(dataSource);
                   String column_order="";
                   if (orderColumn!=null) {
                        column_order = orderColumn + " " + orderType;
                   } else {
                        column_order = " stato DESC "; //this is the invalid index column of the error               
    Map mappa = proc.execute(idGruppo, dataInizio, dataFine, startRow, endRow, column_order);
                   result = (List<VistaFlussiGiornalieri>) mappa.get("recordsetCursor");
                   numeroTotaleRighe = ((BigDecimal)mappa.get("countRow")).intValue();
    response.setSize(numeroTotaleRighe);
              response.setList((List<VistaFlussiGiornalieri>) result);
    private class FlussiGiornalieriStoredProcedure extends StoredProcedure {
            private static final String SQL = "mkt_flussi_giornalieri2";
            public FlussiGiornalieriStoredProcedure(DataSource ds) {             
                super(ds, SQL);
                declareParameter(new SqlParameter("idGruppo", Types.VARCHAR));
                declareParameter(new SqlParameter("dataInizio", Types.DATE));
                declareParameter(new SqlParameter("dataFine", Types.DATE));           
                declareParameter(new SqlParameter("startRow", OracleTypes.NUMBER));
                declareParameter(new SqlParameter("endRow", OracleTypes.NUMBER));
                declareParameter(new SqlParameter("column_order", OracleTypes.VARCHAR));
                //declareParameter(new SqlParameter("order_name", OracleTypes.VARCHAR));
                declareParameter(new SqlOutParameter("recordsetCursor", OracleTypes.CURSOR, VistaFlussiGiornalieriDaoImpl.this));
                declareParameter(new SqlOutParameter("countRow", OracleTypes.NUMBER, VistaFlussiGiornalieriDaoImpl.this));
                //declareParameter(new SqlOutParameter("QUERY_STM", OracleTypes.VARCHAR, VistaFlussiGiornalieriDaoImpl.this));
                compile();
            public Map execute(String idGruppo, Date dataInizio, Date dataFine, int startRow, int endRow, String column_order) {
                 Map inputs = new HashMap();
                 inputs.put("idGruppo", idGruppo);
                 inputs.put("dataInizio", dataInizio);
                 inputs.put("dataFine", dataFine);
                 inputs.put("startRow", startRow);
                 inputs.put("endRow", endRow);
                 inputs.put("column_order", column_order);
                return execute(inputs);
        }When The java class call the oracle procedure I receive this message:
    >
    Caused by: java.sql.SQLException: Invalid index column
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
         at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:385)
         at it.edison.markettracker.dao.spring.VistaFlussiGiornalieriDaoImpl.mapRow(VistaFlussiGiornalieriDaoImpl.java:155)
         at it.edison.markettracker.dao.spring.VistaFlussiGiornalieriDaoImpl.mapRow(VistaFlussiGiornalieriDaoImpl.java:1)
         at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:92)
         at org.springframework.jdbc.core.JdbcTemplate.processResultSet(JdbcTemplate.java:1124)
         at org.springframework.jdbc.core.JdbcTemplate.extractOutputParameters(JdbcTemplate.java:1085)
         at org.springframework.jdbc.core.JdbcTemplate$5.doInCallableStatement(JdbcTemplate.java:997)
         at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:936)
         ... 26 more
    If I call the procedure, from toad, in this way:
    SET serveroutput ON
    DECLARE
    TROVATI SYS_REFCURSOR;
    NUMERO_TROVATI NUMBER;
    BEGIN
          DBMS_OUTPUT.ENABLE(30000);
          dbms_output.put_line('INIZIO');
          Mkt_Flussi_Giornalieri2(1, trunc(sysdate), trunc(sysdate), 100, 50, 'stato DESC', TROVATI, NUMERO_TROVATI);
          dbms_output.put_line('RECORD TROVATI:'||NUMERO_TROVATI);
    END; I don't receive any error message. Why?
    The procedure is:
    CREATE OR REPLACE PROCEDURE Mkt_Flussi_Giornalieri2
    ( idGruppo IN VARCHAR2
    , dataInizio IN DATE
    , dataFine IN DATE
    , startRow IN NUMBER
    , endRow IN NUMBER
    , column_order in varchar2
    --, order_name in varchar2
    , recordsetCursor OUT SYS_REFCURSOR
    , countRow OUT NUMBER
    ) IS
    order_clause varchar2(200) := ' ';
    sql_stm varchar2(32000);
    BEGIN
    IF column_order IS NOT NULL
    THEN
    order_clause := column_order;
    ELSE
    order_clause := ' stato DESC ';
    END IF;
    dbms_output.put_line('clausola:'||order_clause);
    sql_stm:='
         SELECT idflusso, descrizioneFlusso, dataRiferimento, strDataRiferimento,
            stato,  dataElaborazione, ultimoMessaggio, livello, utentiRiferimento,
            exec_seq, provider_description, log_info FROM
      (SELECT idflusso, descrizioneFlusso, dataRiferimento, strDataRiferimento,
            stato,  dataElaborazione, ultimoMessaggio, livello, utentiRiferimento,
            exec_seq, provider_description, log_info FROM
      (SELECT
    temp.flow_id AS idFlusso,
    MKT_FLOW.flow_id || '' - '' || MKT_FLOW.flow_description || ''('' || temp.exec_seq || '')'' AS descrizioneFlusso,
    TO_DATE(temp.date_id,''yyyymmddhh24miss'') AS dataRiferimento,
    TO_CHAR(TO_DATE(temp.date_id,''yyyymmddhh24miss''),''dd/mm/yyyy'')||'' h. ''||TO_CHAR(TO_DATE(temp.date_id,''yyyymmddhh24miss''),''hh24:mi'') AS strDataRiferimento,
    temp.status AS stato, temp.end_time AS dataElaborazione, DECODE(temp.status,3, ERROR_DESC, 1, TRACE_DES) AS ultimoMessaggio,
    DECODE(temp.status,3, error_level, 1, fk_trace_level) AS livello,
    Get_Group_Description(MKT_FLOW.flow_id) AS utentiRiferimento, temp.exec_seq AS exec_seq, mp.provider_description,
                             mp.provider_link, mfc.log_info
    FROM (
      SELECT v.*, tr.TRACE_ID, tr.TRACE_DES , tr.trace_date, tr.fk_trace_level, e.ERROR_ID, e.ERROR_CODE, NVL(e.ERROR_DESC, er.ERROR_DESC) AS ERROR_DESC, e.error_date, e.error_level,
      MIN(e.error_id) OVER (PARTITION BY e.fk_exec_seq) eid,
      MAX(tr.trace_id) OVER (PARTITION BY tr.fk_exec_seq) tid
      FROM (
        SELECT fc.*, MAX(exec_seq) OVER (PARTITION BY flow_id, flow_frequency, n_run, date_id) exsq
        FROM mkt_flow_conf_view fc
        WHERE TRUNC(end_time) >= :1
          AND TRUNC(end_time) <= :2
      ) v, MKT_ERROR er, MKT_FLOW_ERROR e, MKT_FLOW_TRC tr
      WHERE v.exec_seq        = v.exsq
        AND e.fk_exec_seq (+) = v.exec_seq
        AND tr.fk_exec_seq (+) = v.exec_seq
        AND er.error_id (+) = e.error_code
    ) temp
    INNER JOIN MKT_FLOW
    ON MKT_FLOW.flow_id = temp.flow_id AND MKT_FLOW.n_run = temp.n_run AND MKT_FLOW.flow_frequency = temp.flow_frequency
    INNER JOIN MKT_FLOW_GROUP ON MKT_FLOW_GROUP.flow_id = MKT_FLOW.flow_id
    LEFT OUTER JOIN
                             (SELECT DISTINCT flow_id, log_info
                                         FROM mkt_flow_conf) mfc
                             ON mkt_flow.flow_id = mfc.flow_id
                             , mkt_provider mp
    WHERE NVL(error_id, -1) = NVL(eid, -1)
      AND NVL(trace_id, -1) = NVL(tid, -1)
      AND MKT_FLOW_GROUP.group_id=:3
      AND NVL (mkt_flow.fk_provider_id, '' '') =
                                                         NVL (mp.provider_id, '' '') )
      WHERE ROWNUM <= :4
      MINUS
      (SELECT idflusso, descrizioneFlusso, dataRiferimento, strDataRiferimento,
            stato,  dataElaborazione, ultimoMessaggio, livello, utentiRiferimento,
            exec_seq, provider_description, log_info FROM
      (SELECT
    temp.flow_id AS idFlusso,
    MKT_FLOW.flow_id || '' - '' || MKT_FLOW.flow_description || ''('' || temp.exec_seq || '')'' AS descrizioneFlusso,
    TO_DATE(temp.date_id,''yyyymmddhh24miss'') AS dataRiferimento,
    TO_CHAR(TO_DATE(temp.date_id,''yyyymmddhh24miss''),''dd/mm/yyyy'')||'' h. ''||TO_CHAR(TO_DATE(temp.date_id,''yyyymmddhh24miss''),''hh24:mi'') AS strDataRiferimento,
    temp.status AS stato, temp.end_time AS dataElaborazione, DECODE(temp.status,3, ERROR_DESC, 1, TRACE_DES) AS ultimoMessaggio,
    DECODE(temp.status,3, error_level, 1, fk_trace_level) AS livello,
    Get_Group_Description(MKT_FLOW.flow_id) AS utentiRiferimento, temp.exec_seq AS exec_seq, mp.provider_description,
                             mp.provider_link, mfc.log_info
    FROM (
      SELECT v.*, tr.TRACE_ID, tr.TRACE_DES , tr.trace_date, tr.fk_trace_level, e.ERROR_ID, e.ERROR_CODE, NVL(e.ERROR_DESC, er.ERROR_DESC) AS ERROR_DESC, e.error_date, e.error_level,
      MIN(e.error_id) OVER (PARTITION BY e.fk_exec_seq) eid,
      MAX(tr.trace_id) OVER (PARTITION BY tr.fk_exec_seq) tid
      FROM (
        SELECT fc.*, MAX(exec_seq) OVER (PARTITION BY flow_id, flow_frequency, n_run, date_id) exsq
        FROM mkt_flow_conf_view fc
        WHERE TRUNC(end_time) >= :5
          AND TRUNC(end_time) <= :6
      ) v, MKT_ERROR er, MKT_FLOW_ERROR e, MKT_FLOW_TRC tr
      WHERE v.exec_seq        = v.exsq
        AND e.fk_exec_seq (+) = v.exec_seq
        AND tr.fk_exec_seq (+) = v.exec_seq
        AND er.error_id (+) = e.error_code
    ) temp
    INNER JOIN MKT_FLOW
    ON MKT_FLOW.flow_id = temp.flow_id AND MKT_FLOW.n_run = temp.n_run AND MKT_FLOW.flow_frequency = temp.flow_frequency
    INNER JOIN MKT_FLOW_GROUP ON MKT_FLOW_GROUP.flow_id = MKT_FLOW.flow_id
    LEFT OUTER JOIN
                             (SELECT DISTINCT flow_id, log_info
                                         FROM mkt_flow_conf) mfc
                             ON mkt_flow.flow_id = mfc.flow_id
                             , mkt_provider mp
    WHERE NVL(error_id, -1) = NVL(eid, -1)
      AND NVL(trace_id, -1) = NVL(tid, -1)
      AND MKT_FLOW_GROUP.group_id=:7
      AND NVL (mkt_flow.fk_provider_id, '' '') =
                                                         NVL (mp.provider_id, '' '') )
      WHERE ROWNUM <= :8
      )  ) ORDER BY :9' ;
    dbms_output.enable(30000);
    dbms_output.put_line(sql_stm);
    OPEN recordsetCursor FOR sql_stm USING dataInizio, dataFine, idGruppo, endRow, dataInizio, dataFine, idGruppo, startRow, order_clause;
       SELECT COUNT(*) INTO countRow FROM
      (SELECT
    temp.flow_id AS idFlusso,
    MKT_FLOW.flow_id || ' - ' || MKT_FLOW.flow_description || '(' || temp.exec_seq || ')' AS descrizioneFlusso,
    TO_DATE(temp.date_id,'yyyymmddhh24miss') AS dataRiferimento,
    TO_CHAR(TO_DATE(temp.date_id,'yyyymmddhh24miss'),'dd/mm/yyyy')||' h. '||TO_CHAR(TO_DATE(temp.date_id,'yyyymmddhh24miss'),'hh24:mi') AS strDataRiferimento,
    temp.status AS stato, temp.end_time AS dataElaborazione, DECODE(temp.status,3, ERROR_DESC, 1, TRACE_DES) AS ultimoMessaggio,
    DECODE(temp.status,3, error_level, 1, fk_trace_level) AS livello,
    Get_Group_Description(MKT_FLOW.flow_id) AS utentiRiferimento, temp.exec_seq AS exec_seq, mp.provider_description,
                             mp.provider_link, mfc.log_info
    FROM (
      SELECT v.*, tr.TRACE_ID, tr.TRACE_DES , tr.trace_date, tr.fk_trace_level, e.ERROR_ID, e.ERROR_CODE, NVL(e.ERROR_DESC, er.ERROR_DESC) AS ERROR_DESC, e.error_date, e.error_level,
      MIN(e.error_id) OVER (PARTITION BY e.fk_exec_seq) eid,
      MAX(tr.trace_id) OVER (PARTITION BY tr.fk_exec_seq) tid
      FROM (
        SELECT fc.*, MAX(exec_seq) OVER (PARTITION BY flow_id, flow_frequency, n_run, date_id) exsq
        FROM mkt_flow_conf_view fc
        WHERE TRUNC(end_time) >= dataInizio
          AND TRUNC(end_time) <= dataFine
      ) v, MKT_ERROR er, MKT_FLOW_ERROR e, MKT_FLOW_TRC tr
      WHERE v.exec_seq        = v.exsq
        AND e.fk_exec_seq (+) = v.exec_seq
        AND tr.fk_exec_seq (+) = v.exec_seq
        AND er.error_id (+) = e.error_code
    ) temp
    INNER JOIN MKT_FLOW
    ON MKT_FLOW.flow_id = temp.flow_id AND MKT_FLOW.n_run = temp.n_run AND MKT_FLOW.flow_frequency = temp.flow_frequency
    INNER JOIN MKT_FLOW_GROUP ON MKT_FLOW_GROUP.flow_id = MKT_FLOW.flow_id
    LEFT OUTER JOIN
                             (SELECT DISTINCT flow_id, log_info
                                         FROM mkt_flow_conf) mfc
                             ON mkt_flow.flow_id = mfc.flow_id
                             , mkt_provider mp
    WHERE NVL(error_id, -1) = NVL(eid, -1)
      AND NVL(trace_id, -1) = NVL(tid, -1)
      AND MKT_FLOW_GROUP.group_id=idGruppo
      AND NVL (mkt_flow.fk_provider_id, ' ') =
                                                         NVL (mp.provider_id, ' '));
    END Mkt_Flussi_Giornalieri2;
    /Please, could someone help me?
    Thanks. Bye Bye.

    Hi,
    I have solved the problem, I forgot a parameter in the select, so java tells the an error. But now I have another problem. The procedure doesn't execute the order by. I pass the couple column_name order_type in a string as ("provider_description desc") dinamically but the procedure doesn't execute the ordering. Why?
    Thanks, bye bye.

  • Calling procedure with 2 parameters from a dynamic link

    I have just another question-
    I have a procedure testing_del_archive which is being called with 2 parameters...from a dynamic link in my SQL Query.
    The following is my code....
    SELECT re.report_exec_id, re.exec_userid,
    NVL(re.batch_exec_date, re.begin_date) report_date,
    re.rows_returned,
    re.status, re.error,
    f_file_url(re.filename) file_url,
    re.comments,
    ''Archive''archive
    FROM metadev.report_execution re, metadev.report r
    WHERE re.report_id = r.report_id
    AND r.spec_number = :v_spec
    AND re.status <> 'DELETED'
    AND re.exec_userid like (DECODE(:v_user_filter,'ALL','%',:v_user_filter))
    ORDER BY begin_date DESC
    The first parameter is the value in the execution id field and the second argument is hardcoded "Archived"...
    IT GIVES AN ERROR....
    Do you guys know where I am going wrong...

    You missed the ampersand symbol in between the parameters.
    This should be
    ''Archive''archive
    instead of
    ''Archive''archive

  • Calling procedure with 4 output varchar2 gets corrupted (via SQLExecDirect)

    I have a procedure:
    create or replace procedure
    cme.GetNominalIndividualDetails(iNominalIndexID in
    number,sSurname out varchar2,sForenames out varchar2,sCRONumber
    out varchar2,dtDOB out date) AS
    begin
    select Surname,Forenames,CRONumber,DOB into
    sSurname,sForenames,sCRONumber,dtDOB from v_NominalIndividual
    where NominalIndexID = iNominalIndexID;
    exception
    when no_data_found then
    begin
    sSurname:=null;
    sForenames:=null;
    dtDOB:=null;
    sCRONumber:=null;
    end;
    end;
    When I call this procedure from code I always get corrupt
    strings comming back (it looks like they are not null
    terminated) using ODBC with VC++ using Bindparameters with
    SQLExecDirect.
    The latest odbc driver is no help..
    If anyone has a solution please let me know... (it works fine
    with our Sybase / MS SQL server databases).
    I am persuming it is a bug in the oracle odbc ??
    Matt.
    Can you email at [email protected]
    Thanks.

    fyi
    Related to the solution/workaround posted by Luc.
    see "Do Oracle's JDBC drivers support PL/SQL tables/result sets/records/booleans? "
    at http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html#34_05
    regards
    Jan Vervecken

Maybe you are looking for

  • Error While Provisioning User from OIM to OID

    This is the Error I'm getting While Creating a user and provisioning. DOBJ.THROWABLE_IN_SAVE Unhandled throwable java.lang.NoClassDefFoundError in com.thortech.xl.dataobj.tcScheduleItem's save This error happens when i try to provision the user with

  • How to change printer and or system settings to print in color

    How to change printer and or system settings to print in color

  • How can I create xml file automatically from database

    Hi, Can I create a site map drom database.There is table for storing menu details.Is it possible to create an xml file corresponding to a query. How can i configure root menu.xml to incllude this xml file.Please help me.. Thanks

  • How do I convert a compound path into a smart object?

    I'm working on a project and I need to use the free distort tool + ctrl (command for mac users) but it won't work. I found out that I need to convert it to a smart object, from another disscussion, but right clicking the name of it in the layers menu

  • Slow responce for MAX OS mail, safari and firefox

    Hi, I have a puzzeling problem. I have a IMAC intel late 2007 nov with 4gb ram and a 1TB harddisk (850GB disk free space) With SnowLeopard and have run all software updates. My problem is that mail, safari and firefox are running slow. But as I also