Stored PL/SQL function that returns REF CURSOR type

Hello everyone,
I've come through the following problem:
1.- I created an PL/SQL stored procedure which returns a REF CURSOR element, definition looks like this:
PACKAGE PKG_LISTADOS AS
TYPE tuplas IS REF CURSOR;
/* Procedimientos exportados por el paquete */
PROCEDURE inicializarModuloListados;
FUNCTION recaudacionUltimoMes(medioPago DEF_MEDIO_PAGO.MEDIO_PAGO%TYPE)
RETURN tuplas;
2.- Now I would like to call the stored procedure and retrieve the PL/SQL cursor as a ResultSet Java Object. The code I wrote is this:
Connection conn;
XmlDocument paramDef;
conn=poolMgr.getConnection str_poolDBConnection);
try
CallableStatement cstmt=conn.prepareCall("{?=call PKG_LISTADOS.recaudacionUltimoMes(?)}");
cstmt.registerOutParameter(1, java.sql.Types.OTHER);
cstmt.setString(2, "MONEDA");
cstmt.executeQuery();
ResultSet rs=(ResultSet)cstmt.getObject(1);
catch(SQLException sqlE)
3.- However, I can't make it OK, all the time I get the following error:
SQL Error(17004), java.sql.SQLException: Non valid column type
May anyone help me with this, thanks in advance:
Miguel-Angel

<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by angelrip:
Hello everyone,
I've come through the following problem:
1.- I created an PL/SQL stored procedure which returns a REF CURSOR element, definition looks like this:
PACKAGE PKG_LISTADOS AS
TYPE tuplas IS REF CURSOR;
/* Procedimientos exportados por el paquete */
PROCEDURE inicializarModuloListados;
FUNCTION recaudacionUltimoMes(medioPago DEF_MEDIO_PAGO.MEDIO_PAGO%TYPE)
RETURN tuplas;
2.- Now I would like to call the stored procedure and retrieve the PL/SQL cursor as a ResultSet Java Object. The code I wrote is this:
Connection conn;
XmlDocument paramDef;
conn=poolMgr.getConnection str_poolDBConnection);
try
CallableStatement cstmt=conn.prepareCall("{?=call PKG_LISTADOS.recaudacionUltimoMes(?)}");
cstmt.registerOutParameter(1, java.sql.Types.OTHER);
cstmt.setString(2, "MONEDA");
cstmt.executeQuery();
ResultSet rs=(ResultSet)cstmt.getObject(1);
catch(SQLException sqlE)
3.- However, I can't make it OK, all the time I get the following error:
SQL Error(17004), java.sql.SQLException: Non valid column type
May anyone help me with this, thanks in advance:
Miguel-Angel<HR></BLOCKQUOTE>
Do something like the following:
cstmt = conn.prepareCall("{call customer_proc(?, ?)}");
//Set the first parameter
cstmt.setInt(1, 40);
//Register to get the Cursor parameter back from the procedure
cstmt.registerOutParameter(2, OracleTypes.CURSOR);
cstmt.execute();
ResultSet cursor = ((OracleCallableStatement)cstmt).getCursor(2);
while(cursor.next())
System.out.println("CUSTOMER NAME: " + cursor.getString(1));
System.out.println("CUSTOMER AGE: " + cursor.getInt(2));
cursor.close();
null

Similar Messages

  • Deploy resulset of PL\SQL function, that returns ANYTABLE%TYPE

    How can deploy resulset of PL\SQL function, that returns ANYTABLE%TYPE in SQL?

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by angelrip:
    Hello everyone,
    I've come through the following problem:
    1.- I created an PL/SQL stored procedure which returns a REF CURSOR element, definition looks like this:
    PACKAGE PKG_LISTADOS AS
    TYPE tuplas IS REF CURSOR;
    /* Procedimientos exportados por el paquete */
    PROCEDURE inicializarModuloListados;
    FUNCTION recaudacionUltimoMes(medioPago DEF_MEDIO_PAGO.MEDIO_PAGO%TYPE)
    RETURN tuplas;
    2.- Now I would like to call the stored procedure and retrieve the PL/SQL cursor as a ResultSet Java Object. The code I wrote is this:
    Connection conn;
    XmlDocument paramDef;
    conn=poolMgr.getConnection str_poolDBConnection);
    try
    CallableStatement cstmt=conn.prepareCall("{?=call PKG_LISTADOS.recaudacionUltimoMes(?)}");
    cstmt.registerOutParameter(1, java.sql.Types.OTHER);
    cstmt.setString(2, "MONEDA");
    cstmt.executeQuery();
    ResultSet rs=(ResultSet)cstmt.getObject(1);
    catch(SQLException sqlE)
    3.- However, I can't make it OK, all the time I get the following error:
    SQL Error(17004), java.sql.SQLException: Non valid column type
    May anyone help me with this, thanks in advance:
    Miguel-Angel<HR></BLOCKQUOTE>
    Do something like the following:
    cstmt = conn.prepareCall("{call customer_proc(?, ?)}");
    //Set the first parameter
    cstmt.setInt(1, 40);
    //Register to get the Cursor parameter back from the procedure
    cstmt.registerOutParameter(2, OracleTypes.CURSOR);
    cstmt.execute();
    ResultSet cursor = ((OracleCallableStatement)cstmt).getCursor(2);
    while(cursor.next())
    System.out.println("CUSTOMER NAME: " + cursor.getString(1));
    System.out.println("CUSTOMER AGE: " + cursor.getInt(2));
    cursor.close();
    null

  • Call ref cursor functions in function also returning ref cursor?

    In 10g database, I have several functions and procedures, some packaged, that return ref cursors. These work as expected.
    Is there a way to call one or more of these in a new function and return another ref cursor?
    I know this doesn't work, but I hope it conveys the idea.
    function f_get_order_lines
       return sys_refcursor -- or defined ref cursor
    is
      v_ords orders_rcr;
      v_lines lines_rcr;
      x sys_refcursor;
    begin
      v_ords := f_get_orders;
      for rec in v_ords
       loop
        v_lines := f_get_lines;
       ... do other work here...
      end loop;
    return x;
    end;

    Pipelined table functions might do the trick for you, depending you your requirements and the transformations you need to make:
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm#sthref2345

  • Call to Oracle stored procedure that returns ref cursor doesn't work

    I'm trying to use an OData service operation with Entity Framework to call an Oracle stored procedure that takes an number as an input parameter and returns a ref cursor. The client is javascript so I'm using the rest console to test my endpoints. I have been able to successful call a regular Oracle stored procedure that takes a number parameter but doesn't return anything so I think I have the different component interactions correct. When I try calling the proc that has an ref cursor for the output I get the following an error "Invalid number or type of parameters". Here are my specifics:
    App.config
    <oracle.dataaccess.client>
    <settings>
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursor.P_RESULTS" value="implicitRefCursor bindinfo='mode=Output'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.0" value="implicitRefCursor metadata='ColumnName=WINDFARM_ID;BaseColumnName=WINDFARM_ID;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Number;ProviderType=Int32'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.1" value="implicitRefCursor metadata='ColumnName=STARTTIME;BaseColumnName=STARTTIME;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.2" value="implicitRefCursor metadata='ColumnName=ENDTIME;BaseColumnName=ENDTIME;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.3" value="implicitRefCursor metadata='ColumnName=TURBINE_NUMBER;BaseColumnName=TURBINE_NUMBER;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.4" value="implicitRefCursor metadata='ColumnName=NOTES;BaseColumnName=NOTES;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.5" value="implicitRefCursor metadata='ColumnName=TECHNICIAN_NAME;BaseColumnName=TECHNICIAN_NAME;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYID.RefCursor.P_RESULTS" value="implicitRefCursor bindinfo='mode=Output'" />
    </settings>
    OData Service Operation:
    public class OracleODataService : DataService<OracleEntities>
    // This method is called only once to initialize service-wide policies.
    public static void InitializeService(DataServiceConfiguration config)
    // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
    // Examples:
    config.SetEntitySetAccessRule("*", EntitySetRights.All);
    config.SetServiceOperationAccessRule("GetWorkOrdersByWindfarmId", ServiceOperationRights.All);
    config.SetServiceOperationAccessRule("CreateWorkOrder", ServiceOperationRights.All);
    config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
    [WebGet]
    public IQueryable<GetWorkOrdersByWindfarmId_Result> GetWorkOrdersByWindfarmId(int WindfarmId)
    return this.CurrentDataSource.GetWorkOrdersByWindfarmId(WindfarmId).AsQueryable();
    [WebGet]
    public void CreateWorkOrder(int WindfarmId)
    this.CurrentDataSource.CreateWorkOrder(WindfarmId);
    Here is the stored procedure:
    procedure GetWorkOrdersByWindFarmId(WINDFARMID IN NUMBER,
    P_RESULTS OUT REF_CUR) is
    begin
    OPEN P_RESULTS FOR
    select WINDFARM_ID,
    STARTTIME,
    ENDTIME,
    TURBINE_NUMBER,
    NOTES,
    TECHNICIAN_NAME
    from WORKORDERS
    where WINDFARM_ID = WINDFARMID;
    end GetWorkOrdersByWindFarmId;
    I defined a function import for the stored procedure using the directions I found online by creating a new complex type. I don't know if I should be defining the input parameter, WindfarmId, in my app.config? If I should what would that format look like? I also don't know if I'm invoking the stored procedure correctly in my service operation? I'm testing everything through the rest console because the client consuming this information is written in javascript and expecting a json format. Any help is appreciated!
    Edited by: 1001323 on Apr 20, 2013 8:04 AM
    Edited by: jennyh on Apr 22, 2013 9:00 AM

    Making the change you suggested still resulted in the same Oracle.DataAccess.Client.OracleException {"ORA-06550: line 1, column 8:\nPLS-00306: wrong number or types of arguments in call to 'GETWORKORDERSBYWINDFARMID'\nORA-06550: line 1, column 8:\nPL/SQL: Statement ignored"}     System.Exception {Oracle.DataAccess.Client.OracleException}
    I keep thinking it has to do with my oracle.dataaccess.client settings in App.Config because I don't actually put the WindfarmId and an input parameter. I tried a few different ways to do this but can't find the correct format.

  • Calling stored proc from java to return ref cursor

    Hi All,
    We have a requirement to display all the records from a table on a JAVA screen. Due to some constraints, we have to write the query in the stored proc. We are trying to return a result set from the stored proc to the java code by using a ref cursor. Please refer to the code below.
    Following is the PL/SQL proc ?
    procedure sp_user_course2(v1 OUT ref_cursor, persid in varchar2) as
    begin
    open v1 for
    SELECT lrn_exp_id, crs_name FROM emp_crs
    WHERE personid = persid;
    end;
    Here ref_cursor is of TYPE REF CURSOR declared in the package specification.
    The java code is ?
    Callable stmt = conn.prepareCall("call sp_user_course2(?,?)");
    stmt.registerOutParameter(1,OracleTypes.CURSOR);
    stmt.setString(2,emplId);
    stmt.execute();
    OracleCallableStatement tstmt = (OracleCallableStatement) stmt;
    ResultSet rs = tstmt.getCursor (1);
    When I run the program, I get the following error (at stmt.execute()):
    [Oracle][ODBC][Ora]ORA-06553: PLS-306: wrong number or types of arguments in call to 'SP_USER_COURSE2' 6553
    Can anyone tell me what could be the problem with this code? I have read somewhere that REF CURSOR feature is available from Oracle 9i onwards. If so, then, is there any workaround for mapping REF CURSOR to Resultsets in Oracle 8i?

    These may help
    http://www.google.co.uk/search?q=jdbc+OracleTypes.CURSOR+tutorial

  • EBS ISG using custom PL/SQL functions that return XMLType

    Hi,
    We have a custom PL/SQL package that we use for interfacing systems and some of the functions in this package ruturn an XMLType. We want to deploy the package functions as web services through the ISG, but it is not working as expected. When deployed through the ISG, the functions with XMLType return type produce a null response from the ISG (they work fine when called in SQL or PL/SQL; functions with non-XMLTypes work fine).
    If we change the return type to CLOB (and use getClobVal() on the XMLType) then we get a response from the ISG, but it changes all the angle-brackets in the CLOB (which is still arbitrary XML text) to &lt; &gt; ...
    What is the proper way to get the complex XMLType output through the ISG? Anyone have any more experience?
    Thanks,
    --Walt                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Alex,
    For the predicate groups that are indexed/stored, the exact operator types (as in equality, inequality, like etc) that are indexed are specified while assigning the default index parameters. In the following example, exf$indexoper is used to specify the list of indexed operators.
    BEGIN
      DBMS_EXPFIL.DEFAULT_INDEX_PARAMETERS('Car4Sale',
        exf$attribute_list (
           exf$attribute (attr_name => 'HorsePower(Model, Year)',
                          attr_oper => exf$indexoper('=','<','>','>=','<='),
                          attr_indexed => 'FALSE')    --- stored predicate group
    END;
    /You can find more information about exf$indexoper at
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/t_expfilobj.htm#ARPLS153
    Could you confirm that you chose to index 'is null' and 'is not null' while assigning the default index parameters ? This information is available in OPERATOR_LIST column of the USER_EXPFIL_DEF_INDEX_PARAMS view.
    Hope this helps,
    -Aravind.

  • How to call functions that return package local types?

    Hi everyone, I have a Pl/Sql function in a package that returns a package-local type.
    I would like to call this function from Java, but I don't know what to pass to "statement.registerOutParameter()"
    (it gives this error:
    Unable to resolve type: "XDRIVE_B2B.TEST1.MYTYPE)
    Here's the simple version with one package:
    package TESTPKG IS
    TYPE MYTYPE IS VARRAY(1) OF INTEGER;
    FUNCTION FCT2 RETURN MYTYPE;
    end;
    package body testpkg IS
    FUNCTION FCT2 RETURN MYTYPE IS
    BEGIN
    RETURN mytype(55);
    END;
    end;
    and here's the java code:
    void javatest(OracleConnection conn)
    throws SQLException
    String sql = "{ call ? = testpkg.fct2() }";
    OracleCallableStatement st =
    (OracleCallableStatement) conn.prepareCall(sql);
    st.registerOutParameter(1, OracleTypes.ARRAY, "MYUSERNAME.TESTPKG.MYTYPE");
    st.execute();
    and as I said above, the java code fails with:
    java.sql.SQLException: Fail to construct descriptor: Unable to resolve type: "MYUSERNAME.TEST1.MYTYPE"
    I can't really have this type live outside of a package because in the real case, it's not a VARRAY(1) of integer, it's a VARRAY(1) of MYTABLE%ROWTYPE, which only seems to compile inside a package.
    thanks for any opinions,
    george moudry
    null

    JDBC, JPublisher, and SQLJ do not support PL/SQL-only types. This includes PL/SQL index tables and record types.

  • Subquery not allowed - PL/SQL Function Body returning bolean

    Is subquery is not allowed in PL/SQL Expresion.????
    I am using the following query in one of my derived report column but I am getting the error.
    BEGIN
    if :COL1<>'abc' and :COL2 in (select deptno from dept1) then
    return 1;
    elsif :COL1<>'abc' and :COL2 in (select deptno from dept2) then
    return 0;
    elsif :COL1<>'abc' and :COL2 in (select deptno from dept3) then
    return 1;
    else
    return 0;
    end if;
    END;
    secondly CAN I use return value such as 'ABC' or 'XYZ' other than 0,1.
    Error-
    Invalid function body condition: ORA-06550: line 4, column 8: PLS-00405: subquery not allowed in this context ORA-06550: line 2, column 3: PL/SQL: Statement ignored
    -----------------

    Hi Deepak,
    There are at least methods.
    1 - You could create a SQL function that returned 0 or 1 and use that in your statement
    2 - You could use a CASE clause in the SQL statement
    As I don't have your dept1/2/3 tables, I've tried the following on the sample EMP/DEPT tables:
    SELECT EMPNO,
    ENAME,
    SAL,
    COMM,
    DEPTNO,
    CASE WHEN DEPTNO IN (SELECT DEPTNO FROM DEPT) THEN
      CASE WHEN ENAME LIKE '%A%' THEN NVL(SAL,0) + NVL(COMM,0) ELSE 456 END
    ELSE
       CASE WHEN DEPTNO NOT IN (SELECT DEPTNO FROM DEPT) THEN
         CASE WHEN ENAME LIKE '%A%' THEN NVL(SAL,0) + NVL(COMM,0) ELSE 123 END
       ELSE
         789
       END
    END "TOTAL"
    FROM EMPThis returns the values I expect:
    EMPNO     ENAME     SAL     COMM     DEPTNO     TOTAL
    7936     ATD     3000     -      40     3000
    7958     dino4     -      -      -      789
    7839     KINGS     5000     -      40     456
    7698     BLAKES     2850     -      30     2850
    7782     CLARK     2450     -      10     2450
    7566     JONES     2975     -      30     456
    7788     SCOTT     3000     -      20     456
    7902     FORD     3000     -      40     456
    7369     SMITH     800     -      20     456
    7499     ALLEN     1600     300     30     1900Obviously, you may have to experiment with the various CASE statements, but it will work using just a sql select statement.
    Andy

  • DB  Adapter Calling DB Procedure that returns a Record Type

    I am trying to call a PL/SQL procedure that returns a Record Type and a VARCHAR2 and I'm getting this error:
    <Faulthttp://schemas.xmlsoap.org/soap/envelope/>
    <faultcode>env:Server</faultcode>
    <faultstring>java.sql.SQLException: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'MY_PROC.GET_ID' ORA-06550: line 1, column 7: PL/SQL: Statement ignored </faultstring> </Fault>
    Is there something different I need to do to handle the Record Type OUT parameter?
    Thanks.

    The adapter configuration wizard should take care of the Record Type for you. It should invoke JPublisher to create an equivalent Object type and a package containing a wrapper that will be called by the adapter runtime. The package also contains conversion functions for converting between your Record Type and the generated Object type. Maybe it would help if you posted the signature of your stored procedure (not the body).

  • Function calling stored procedure that returns a cursor into a LOV

    Hello,
    Is it possible in HTML DB to implement a process that has a function that calls a stored procedure that returns a cursor, used to then populate a select list?
    Or can I do a function call to a stored procedure in the 'List of values definition' box for the item itself that returns a cursor to populate the item's select list?

    Hi Vikas,
    Actually, I just found another posting that shows how to do what I'm looking for:
    Re: Filling a LOV with a cursor
    Check it out. I posted another question in response to that discussion...maybe you could answer that? Thanks!
    Laura

  • How to read my cursor that is ref cursor returning user defined type

    Hi
    I have types defined as follows:
    TYPE MY_RECORD IS RECORD (
    COL1 TABLE1.COL1%TYPE,
    COL2 TABLE1.COL2%TYPE
    TYPE MY_CURSOR IS REF CURSOR
    RETURN MY_RECORD;This is used as return type in a stored procedure.
    I have a pl/sql block where I make a call to the SP that returns this cursor.
    How can I read individual values being returned from SP?

    SQL> create or replace package pkg
    as
       type my_record is record (col1 emp.empno%type, col2 emp.ename%type);
       type my_cursor is ref cursor
          return my_record;
       procedure p (cur out my_cursor);
    end pkg;
    Package created.
    SQL> create or replace package body pkg
    as
       procedure p (cur out my_cursor)
       as
       begin
          open cur for
             select   empno, ename
               from   emp
              where   rownum <= 2;
       end p;
    end pkg;
    Package body created.
    SQL> declare
       cur     pkg.my_cursor;
       e_rec   pkg.my_record;
    begin
       pkg.p (cur);
       loop
          fetch cur into   e_rec;
          exit when cur%notfound;
          dbms_output.put ('Empno: ' || e_rec.col1);
          dbms_output.put_line ('; Ename: ' || e_rec.col2);
       end loop;
       close cur;
    end;
    Empno: 7369; Ename: SMITH
    Empno: 7499; Ename: ALLEN
    PL/SQL procedure successfully completed.

  • Using XI - RFC table and an Oracle stored procedure that returns a cursor.

    I need to create an interface using XI between an RFC table and an Oracle stored procedure that returns a cursor.  We are on oarcle 9.2 and  SP12.
    My stored procedure looks something like this:
    CREATE OR REPLACE
    PROCEDURE testproc_xi2 (p_recordset1 OUT SYS_REFCURSOR,
                                             in_quoteid IN varchar2 )
    AS
    BEGIN
      OPEN p_recordset1 FOR
       SELECT  q.quote_id,
                     q.modified_by,
                     q.quote_status,
                     q.total_cost
                FROM quote q
               WHERE q.quote_id = in_quoteid
                 AND q.total_cost > 0 ; 
    END testproc_xi2 ;
    My RFC has table and  one import parameter .
    I wanted to know how to create the data type for the ref cursor? and also for the table type in the RFC?
    CAN XI handle multi rows coming from a Stored procedure? Are there any other alternative methods if this is not supported?Any pointers to this would be helpful.
    I have called a Oracle SP from an RFC before, but that interface had one input parameter going to the stored procedure from the RFC and about 6 o/p parameters coming from the Stored procedure. This works fine.
    Thanks for the help.
    Mala

    Mala,
    i dont think there is anything called an rfc table...RFC stands for remote function call. That in essence would imply you need a rfc to jdbc connection.
    yes XI can handle multiple rows cooming from the the stored procedure if you have them mapped appropriately.
    Now as to how to create the data type within xi , you need to know what fields are going to be returned and whether they are nested and then just create them as you would for an xml
    for ex
    <Details>
      <FirstName>
    <LastName>
    </Details>
    that in xi would be smthing like
    Details  type of data occurence
    FirstName type of data occurence
    LastName type of data occurence.
    Hope that helps.
    If it does dont forget the points..:-)

  • How to execute stored procedure that returns a cursor?

    How to execute a stored procedure that returns a cursor?
    Follow the code:
    CREATE OR REPLACE PROCEDURE stp_cashin_grupo
    (p_func IN VARCHAR
    ,p_cod_grup IN Integer
    ,p_des_grup IN VARCHAR
    ,p_logi IN VARCHAR
    ,p_curs_rset OUT infoc.pck_cashin_grupo.curs_rset
    IS
    BEGIN
    if p_func = '1' then
    OPEN p_curs_rset FOR
    select
    cod_grup
    ,des_grup
    ,dat_manu_grup
    ,des_logi_manu
    from infoc.tbl_cashin_grupo
    order by des_grup;
    end if;
    END stp_cashin_grupo;
    and the package:
    CREATE OR REPLACE PACKAGE pck_cashin_grupo
    AS
    TYPE curs_rset IS REF CURSOR;
    END pck_cashin_grupo;
    My question is how to execute in sql plus?
    EXEC stp_cashin_grupo('1',0,'','465990', my doubt is how to pass the cursor as return
    Thanks

    my doubt is how to pass the cursor as returnExample :
    TEST@db102 > var c1 refcursor;
    TEST@db102 > create or replace procedure ref1 (
      2     v1 in varchar2,
      3     cur1 out sys_refcursor)
      4  is
      5  begin
      6     open cur1 for 'select * from '||v1;
      7  end;
      8  /
    Procedure created.
    TEST@db102 > exec ref1('dept',:c1);
    PL/SQL procedure successfully completed.
    TEST@db102 > print c1
        DEPTNO DNAME          LOC
            10 ACCOUNTING     NEW YORK
            20 RESEARCH       DALLAS
            30 SALES          CHICAGO
            40 OPERATIONS     BOSTON
    TEST@db102 >

  • Problem with XSU when trying to execute pl/sql package returning ref cursor

    Hi,
    I'm exploring xsu with 8i database.
    I tried running sample program which I took from oracle
    documentation. Here is the details of these.
    ------create package returning ref cursor---
    CREATE OR REPLACE package testRef is
         Type empRef IS REF CURSOR;
         function testRefCur return empRef;
    End;
    CREATE OR REPLACE package body testRef is
    function testRefCur RETURN empREF is
    a empREF;
    begin
    OPEN a FOR select * from emp;
    return a;
    end;
    end;
    ---------package successfully created-----
    Now I use java program to generate xml data from ref cursor
    ------------java program ----------
    import org.w3c.dom.*;
    import oracle.xml.parser.v2.*;
    import java.sql.*;
    import oracle.jdbc.driver.*;
    import oracle.xml.sql.query.OracleXMLQuery;
    import java.io.*;
    public class REFCURt
    public static void main(String[] argv)
    throws SQLException
    String str = null;
    Connection conn = getConnection("scott","tiger"); //
    create connection
    // Create a ResultSet object by calling the PL/SQL function
    CallableStatement stmt =
    conn.prepareCall("begin ? := testRef.testRefCur();
    end;");
    stmt.registerOutParameter(1,OracleTypes.CURSOR); // set
    the define type
    stmt.execute(); // Execute the statement.
    ResultSet rset = (ResultSet)stmt.getObject(1); // Get the
    ResultSet
    OracleXMLQuery qry = new OracleXMLQuery(conn,rset); //
    prepare Query class
         try
    qry.setRaiseNoRowsException(true);
    qry.setRaiseException(true);
    qry.keepCursorState(true); // set options (keep the
    cursor alive..
         System.out.println("..before printing...");
    while ((str = qry.getXMLString())!= null)
    System.out.println(str);
         catch(oracle.xml.sql.OracleXMLSQLNoRowsException ex)
    System.out.println(" END OF OUTPUT ");
    qry.close(); // close the query..!
    // qry.close(); // close the query..!
    // Note since we supplied the statement and resultset,
    closing the
    // OracleXMLquery instance will not close these. We would
    need to
    // explicitly close this ourselves..!
    stmt.close();
    conn.close();
    // Get the connection given the user name and password..!
    private static Connection getConnection(String user, String
    passwd)
    throws SQLException
    DriverManager.registerDriver(new
    oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:thin:@xxxx:1521:yyyy",user,passwd);
    return conn;
    when I ran the program after successful compilation,I got the
    following error
    ==========
    Exception in thread "main" oracle.xml.sql.OracleXMLSQLException:
    1
    at oracle.xml.sql.core.OracleXMLConvert.getXML(Compiled
    Code)
    at oracle.xml.sql.query.OracleXMLQuery.getXMLString
    (OracleXMLQuery.java:263)
    at oracle.xml.sql.query.OracleXMLQuery.getXMLString
    (OracleXMLQuery.java:217)
    at oracle.xml.sql.query.OracleXMLQuery.getXMLString
    (OracleXMLQuery.java:194)
    at REFCURt.main(Compiled Code)
    ============================
    Can anybody tell me why I'm getting this error.Am I missing any
    settings?
    thanks

    We are using 8.1.7 Oracle db with latest xdk loaded.
    am I missing any settings?

  • Migrating Functions that return TABLE from SQL Server to Oracle

    I have some functions in SQL Server that return a TABLE datatype. When these functions are moved to Oracle 9i using Migration Workbench, they give compilation errors. In the migrated function it says that the DDL stmt is passed to the ddl file, but the table is not created. I checked the ddl stmt for temporary tables and it is wrong. Its a create table stmt with no size for varchars and we can't even edit these stmts in the workbench.
    Also the migrated function has the table name for return type, which doesn't works in Oracle. Oracle needs a datatype to be returned from Oracle.
    How do we return a table from a function?

    Yes.
    If you do not enclose the object names (table/view/index etc) in double-quotes, they are stored in uppercase format in the data dictionary.
    If you enclose them in quotes, they are stored in the same case ans you entered. As such, while accessing such objects, you need to tell Oracle not to convert the names to uppercase, hence the requirement to supply the names in quotes.

Maybe you are looking for

  • Exit or Badi to block document after Reset Cleared Items in FF.5

    Hi, When you run FF.5 and some rejected documents are returned by the bank, I have to block the document after reset cleared items with a especific payment block key. Anyone already done something similar? Tks!

  • How to make a code in which i have to detect 3 objects

    Hello everyone, I am new in Labview. I want to make a code in which i have to detect 3 objects and they are in different shapes (rectangle, triangle etc). 1. How many objects in image. 2. What is the size of each object in image 3. At what position t

  • CRM Component missing in CRM BI

    Hi Experts, We are implementing CRM5.0 SR3. Installations were completed. In Dev, QA and Prod when i am applying BI transaction code (RSA1) its indicating me 'you can only work in client001'. I implemented all building blocks(creating logical system

  • I have a serieuse probleme with a luanguages of N7...

    hi my brothers i have N70 and yesterday i has upload a v 5.0638.3.0.1 to my phone and in the final of upload all is normaly and the phone started normaly but after restare a phone the language has changed and i trought to change it but it can't chang

  • CS6 not opening

    Since receiving Adobe's invitation to join Creative Cloud, today, I can't get passed the offer and open CS6; when I decline the offer it also halts process of opening CS6. Am I alone with this problem? ajlinafrica