SYS_REFCURSOR PARAMETER

Hi,
This is my examples
CREATE OR REPLACE
type R_VALUE_DATE IS OBJECT
VALUE_DATE DATE,
DATE_VALUE NUMBER(30,10)
CREATE OR REPLACE
type T_VALUE_DATE IS TABLE OF R_VALUE_DATE;
CREATE OR REPLACE package Z_Test
is
procedure read_data2;
procedure read_data;
end;
CREATE OR REPLACE package body Z_Test
is
procedure populate_data(O_TAB OUT SYS_REFCURSOR)
is
v_tab T_VALUE_DATE := T_VALUE_DATE();
begin
v_tab.extend;
v_tab(v_tab.last) := R_VALUE_DATE(sysdate,1);
v_tab.extend;
v_tab(v_tab.last) := R_VALUE_DATE(sysdate+1,2);
v_tab.extend;
v_tab(v_tab.last) := R_VALUE_DATE(sysdate+3,3);
OPEN O_TAB FOR SELECT * FROM TABLE(v_tab);
end;
procedure read_data2
is
v_tab sys_refcursor;
v_date date;
v_val number;
begin
populate_data(v_tab);
loop
fetch v_tab into v_date,v_val;     
     exit when v_tab%notfound;
     dbms_output.put_line(v_date||' - '||v_val);
end loop;
end;
procedure read_data
is
v_date date;
v_val number;
O_TAB SYS_REFCURSOR;
begin
z_test2.read_data(O_TAB);
loop
fetch O_tab into v_date,v_val;     
     exit when O_tab%notfound;
     dbms_output.put_line(v_date||' - '||v_val);
end loop;
end;
end;
CREATE OR REPLACE package Z_Test2
as
procedure read_data(O_TAB OUT SYS_REFCURSOR);
end;
CREATE OR REPLACE package body Z_Test2
as
procedure populate_data(O_TAB OUT SYS_REFCURSOR)
is
v_tab T_VALUE_DATE := T_VALUE_DATE();
begin
v_tab.extend;
v_tab(v_tab.last) := R_VALUE_DATE(sysdate,1);
v_tab.extend;
v_tab(v_tab.last) := R_VALUE_DATE(sysdate+1,2);
v_tab.extend;
v_tab(v_tab.last) := R_VALUE_DATE(sysdate+3,3);
OPEN O_TAB FOR SELECT * FROM TABLE(v_tab);
end;
procedure read_data(O_TAB OUT SYS_REFCURSOR)
is
v_test number(1) := 0;
begin
populate_data(O_TAB);
v_test := 1;
end;
end;
I don't understand why when I call Z_TEST.READ_DATA2 it works and when I call Z_TEST.READ_DATA it does not work.
Message was edited by:
Zabo

I simplify my example.
I have the 2 following packages.
When I call T2.P3, I got the following errors ORA-06504.
What I am doing wrong ?
Thks.
CREATE OR REPLACE package T1
is
procedure P1(RST OUT SYS_REFCURSOR);
procedure P2(RST OUT SYS_REFCURSOR);
end;
CREATE OR REPLACE package body T1
is
procedure P1(RST OUT SYS_REFCURSOR)
is
begin
OPEN RST FOR SELECT 1 FROM DUAL;
end;
procedure P2(RST OUT SYS_REFCURSOR)
is
v_rst number(1);
begin
P1(RST);
loop
fetch RST into v_rst;
exit when RST%NOTFOUND;
dbms_output.put_line(v_rst);
end loop;
end;
end;
CREATE OR REPLACE package T2
is
procedure P3;
end;
CREATE OR REPLACE package body T2
is
procedure P3
is
RST SYS_REFCURSOR;
v_rst number(1);
begin
T1.P2(RST);
loop
fetch RST into v_rst;
exit when RST%NOTFOUND;
dbms_output.put_line(v_rst);
end loop;
end;
end;
Message was edited by:
Zabo

Similar Messages

  • Collections

    hi this vinod,
    i has been migrated from SQL Server to Oracle. In Sql Server stored procedures i created temp tables . But in PLSQL stored procedure how can get that.
    Create PROCEDURE xx
    Declare @report_table table(P_Id int,PRec_No int,PRec_Amt numeric(25,0))
    begin
    insert into @report_table values(10,20000)
    end
    how can i do it in PLSQL

    Misuse of temporary tables when migrating code from another database to Oracle is a frequent mistake.
    In Oracle, you create a temporary table as a permanent object using the "CREATE GLOBAL TEMPORARY TABLE ..." command.
    You can create these as either "ON COMMIT DELETE ROWS" or "ON COMMIT PRESERVE ROWS".
    Each session's data is private and when the session goes, if you've done the preserve rows option and haven't already deleted it, the data goes.
    Depending on how you're using the temporary table and any result set which might be used against it in a client, you might find you need to have "on commit preserve rows" for the data/table to be usable.
    However, you might well find that you don't need a temporary table at all. In my experience of seeing non-Oracle code migrated into Oracle, at least 8 times out of 10, the preferred Oracle approach would be to use a more complicated join, or a collection.
    If you're returning a result set to the client, regardless of whether you're using a temporary table, more joins in the SQL, or collections, you're likely going to be returning a refcursor to the client probably using a procedure that returns a sys_refcursor parameter and in the procedure using a OPEN <sys_refcursor_parameter_name> FOR <your_sql>
    Message was edited by:
    dombrooks

  • Migrating from SQL Server to ORACLE using SqlDeveloper tool - IN OUT CURSOR

    Hi All,
    I am new to Oracle. I am asked to migrate a database from SQL Server to ORACLE. I have migrated all the SP's and functions except 2. I am facing the following problem. Pls do reply me if anyone knows the solution since I am struggling for the past 2 days for these two functions
    the function is as follows in ORACLE.
    create or replace
    FUNCTION ABC
    AA IN VARCHAR2,
    BB IN DATE,
    CV_1 IN OUT SYS_REFCURSOR
    When I tried to call from some other function its showing me an error.
    I called from another function as follows:
    ABC(CC,DD,CV_2);
    Shall I know how to call the above function? I feel someone has faced the same problem before. Thanks in advance for the help.
    Thanks,
    Srinivasan.T

    Its returing a number only. I am just giving part of the function.
    create or replace
    FUNCTION ABC
    AA IN VARCHAR2,
    DD IN DATE,
    CV_1 IN OUT SYS_REFCURSOR
    RETURN NUMBER
    AS
    When I call the function which has a IN OUT SYS_REFCURSOR as a parameter I am facing this problem.
    I need to know how to call a function which has the IN OUT SYS_REFCURSOR parameter.
    Thanks,
    Srinivasan.T

  • How to call a procedure with SYS_REFCURSOR OUT parameter

    Hi,
    Using Oracle 11g R2.
    I'd like to know if it is possible to display the results of a SYS_REFCURSOR in a query. For example, if I had the following stored procedure
    create or replace procedure testprocedure (result OUT sys_refcursor)
    as
    begin
       open result for
          select 1 from dual
          union all
          select 2 from dual;
    end;
    I'd like to call this procedure similar to the way a query is called and executed. Like this
    select * from testprocedure
    I've seen plenty of examples on the web which show how it is possible to loop through results of a sys_refcursor inside of an anonymous block and display the results using dbms_output.putline, but this isn't the method I am looking for.

    I'd like to know if it is possible to display the results of a SYS_REFCURSOR in a query. For example, if I had the following stored procedure
    No - you can only use schema object types (SQL) in SQL queries and only then if you call a function.
    The function can return a SQL collection type or it can be a PIPELINED function whose return value is a SQL collection type. Either way your query will use the TABLE function and be of the form:
    select * from TABLE(testfunction);
    This is sample code for a PIPELINED function based on the SCOTT.EMP table. The function takes a department number parameter and returns the EMP rows for that department:
    -- 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))

  • Performance issue with using out parameter sys_refcursor

    Hello,
    I'm using Oracle 10g, with ODP.Net in a C# application.
    I'm using about 10 stored procedures, each having one out parameter of sys_refcursor type. when I use one function in C# and call these 10 sp's, it takes about 78ms to excute the function.
    Now to improve the performance, I created one SP with 10 output parameters of sys_refcursor type. and i just call this one sp. the time taken has increased , not it takes abt 95ms.
    is this the right approach or how can we improve the performance by using sys_refcursor.
    please suggest, it is urgent, i'm stuck up with this issue.
    thanks
    shruti

    With 78ms and 95ms are you talking about milliseconds or minutes? If it's milliseconds then what's the problem and does it really matter if there is a difference of 17 milliseconds as that could just be caused by network traffic or something. If you're talking minutes, then we would need more information about what you are attempting to do, what tables and processing is going on, what indexes you have etc.
    Query optimisation tips can be found on this thread.. When your query takes too long ....
    Without more information we can't really tell what's happening.

  • Sys_refcursor vs collection parameter

    When providing a result set as a function parameter, are there any advantages/disadvantages to using a sys_refcursor vs a user-defined collection type?

    >
    I was planning on iterating through the ref cursor and constructing a collection, then using table() to include it in the JOIN. Is that approach viable?
    >
    No - Justin already told you to use a pipelined function. The function can be treated as a table just like you want.
    Try this samle code in the SCOTT schema.
    -- 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))Now you can join that 'table' to the dept table
    SQL> select * from dept where deptno in (select deptno from table(get_emp(20)));
        DEPTNO DNAME          LOC
            20 RESEARCH       DALLAS
    SQL>Isn't that what you said you wanted to do?

  • OUT parameter with NOCOPY hint of type SYS_REFCURSOR

    Hi,
    I am having a procedure which returns a set of 100+ records (each record having 10+ columns) through a OUT parameter of type SYS_REFCURSOR.
    These output records are used in JAVA code for fecthing the resultset and process data.
    Will it make any difference in performance if I use NOPCOPY compiler hint in this procedure (especially I am interested in the interaction between JAVA and PLSQL, with and without NOCOPY parameter).
    Thanks.
    Edited by: user2946813 on Mar 25, 2012 9:15 PM

    user2946813 wrote:
    Hi RP,
    Thanks for the answer.
    So the PLSQL OUT parameter of type SYS_REFCURSOR would be passing just a reference (memory address) to JAVA.
    This behavior is same with or without NOCOPY. Is my understanding correct?
    Thanks.Yes. A ref cursor is just a pointer to a query, not a result set of data. Using NOCOPY or not is pointless (excuse the pun) because, no matter how much data is going to get returned, the pointer itself is no smaller or larger in size, and thus using NOCOPY won't improve performance or save resources.
    {thread:id=886365}

  • OUT PARAMETER SYS_REFCURSOR ?

    hI , i HAVE THE FO9LLOWING CODE..wHICH CALLS A PROCEDURE WHICH HAS OUT PARAMETER AS SYS_REFCURSOR. out_par.
    pm_saveproduct.pm_saveproduct('etl',v_product_data_type,out_par);The called procedure populates the out_par as follows.
    OPEN out_status FOR
                      SELECT lv_prod_id, 'S',
                             'Successfully updated product data'
                        FROM DUAL;Now how can i read these values in my main proc?

    -- This gives Nuric or value error.
    check
    lv_prod_id INTEGER;
    while in fetch statement if some parameter is fetching -ve value then
    this error occurs.
    try exixting with +ve values only                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Using CASE statement in Procedure,  SYS_REFCURSOR as OUT parameter

    Hi all,
    What is the mistake in this procedure
    create or replace procedure ConditionalSelect( param1 number, refCur IN OUT SYS_REFCURSOR ) is     
    begin
    case
    when param1 = 1 then open refCur for select * from AA;
    when param1 = 2 then open refCur for select * from EMPLOYEE;
         end;          
    end;
    The error i am getting is
    Error
    [row:1,col:1] ORA-24344: success with compilation error
    [row:8,col:5] PLS-00103: Encountered the symbol ";" when expecting one of the following:
    case
    The symbol "case" was substituted for ";" to continue.
    Thanks in advance
    pal

    a. you are missing an "end case;"
    b. in select - use case only with end - in pl/sql you shulde use "end case"
    like "end loop", "end if"
    c. case is much more easy to read then a bunch of if's and else if's and else.
    Amiel.

  • Query with parameter as Array (UDT) very slow

    Hi.
    I have following Problem. I try to use Oracle Instant Client 11 and ODP.NET to pass Arrays in SELECT statements as Bind Parameters. I did it, but it runs very-very slow. Example:
    - Inittial Query:
    SELECT tbl1.field1, tbl1.field2, tbl2.field1, tbl2.field2 ... FROM tbl1
    LEFT JOIN tbl2 ON tbl1.field11=tbl2.field0
    LEFT JOIN tbl3 ON tbl2.field11=tbl3.field0 AND tbll1.field5=tbl3.field1
    ...and another LEFT JOINS
    WHERE
    tbl1.field0 IN ('id01', 'id02', 'id03'...)
    this query with 100 elements in "IN" on my database takes 3 seconds.
    - Query with Array bind:
    in Oracle I did UDT: create or replace type myschema.mytype as table of varchar2(1000)
    than, as described in Oracle Example I did few classes (Factory and implementing IOracleCustomType) and use it in Query,
    instead of IN ('id01', 'id02', 'id03'...) I have tbl1.field0 IN (select column_value from table(:prmTable)), and :prmTable is bound array.
    this query takes 190 seconds!!! Why? I works, but the HDD of Oracle server works very hard, and it takes too long.
    Oracle server we habe 10g.
    PS: I tried to use only 5 elements in array - the same result, it takes also 190 seconds...
    Please help!

    I did (some time ago and it was a packaged procedure) something like
    Procedure p(p_one in datatype,p_two in datatype,p_dataset out sys_refcursor) is
      the_sql varchar2(32000);
      the_cursor sys_refcursor;
    begin
      the_sql = 'WITH NOTIFICACAO AS( ' ||
                '      SELECT ' ||
                '       t1.cd_consultora, ' ||
                '                               where       t1.dt_notificacao_cn >= to_date(''01/09/2006'',''dd/mm/yyyy'') ' ||  -- note the ''
                '           where rownum <= :W_TO_REC) ' ||   -- parameter 1
                '         where r_linha >= :W_FROM_REC ';     -- parameter 2
      open the_cursor for the_sql using p_one,p_two;  -- just by the book
    end p;if I remember correctly
    Regards
    Etbin

  • Table name as parameter to function

    Hi all,
    can anybody help me on the below issue..
    i have a function like this:
    **create or replace**
    **function "IL_SUM_AVG_FN" return number is**
    **cursor c1 is**
    **     select     sum_avg_val value**
    **     from     wel_10_tab**
    **     where     type='1';**
    **v_sum number;**
    **v_count number;**
    **BEGIN**
    **     v_sum:=0;**
    **     v_count:=0;**
    **     for i in c1 loop**
    **          if v_count=0 then**
    **               v_sum:=i.value;**
    **          else**
    **               v_sum:=abs(i.value+v_sum);**
    **          end if;**
    **          v_count:=v_count+1;**
    **     end loop;**
    **     return v_sum;**
    **END;**
    now my requirement is like..i want to pass a value as parameter to the function..say i will pass 10 or11 or 12
    then it should change the table name in the cursor according to the parameter.i.e
    if the parameter is 10 it should be: select sum_avg_val value from wel_10_tab where type='1';
    if the parameter is 11 it should be: select sum_avg_val value from wel_11_tab where type='1';
    if the parameter is 12 it should be: select sum_avg_val value from wel_12_tab where type='1';
    parameter has only these three possible values..
    how to achieve this?
    please help..

    Hi,
    you can do without execute immediate and one cursor is sufficient, if you use open cursor for ...:
    set serveroutput on;
    drop table TestTab1;
    drop table TestTab2;
    create table TestTab1 (
         val number
    create table TestTab2 as (select * from TestTab1 where 0 = 1);
    create or replace procedure TestProc (
         TableName in varchar2)
    is
         rec TestTab1%rowtype;
         cur sys_refcursor;
         curStr varchar2(1024) := 'select * from ' || TableName;
    begin
         open cur for curStr;
         loop
              fetch cur into rec;
              exit when cur%notfound;
              dbms_output.put_line ('value = ' || rec.val);
         end loop;
    end;
    insert into TestTab1 (val) values (1);
    insert into TestTab1 (val) values (2);
    insert into TestTab1 (val) values (3);
    insert into TestTab1 (val) values (4);
    insert into TestTab2 (val) values (101);
    insert into TestTab2 (val) values (102);
    insert into TestTab2 (val) values (103);
    insert into TestTab2 (val) values (104);
    begin TestProc('TestTab1'); end;
    begin TestProc('TestTab2'); end;
    /regards,
    Frank
    Edited by: user8704911 on Jul 11, 2011 10:35 PM
    Edited by: user8704911 on Jul 11, 2011 10:36 PM

  • Getting error while Calling Oracle Stored Procedure with output Parameter

    HI All,
    From long days i am working on this but i unable to solve it.
    Even i have studied so many forums in SAP but i didn't find the solution.
    I am calling Oracle Store procedure with 3 inputs and 1 output without cursor.
    Store Procedure:-
    CREATE OR REPLACE PROCEDURE PDS.send_rm
    IS
    proc_name           VARCHAR2(64) := 'send_rm';
    destination_system  VARCHAR2(32) := 'RAWMAT';
    xml_message         VARCHAR2(4000);
    status_code         INTEGER;
    status_message      VARCHAR2(128);
    debug_message       VARCHAR2(128);
    p_ret               INTEGER;
    BEGIN
      DBMS_OUTPUT.PUT_LINE( proc_name || ' started' );
      xml_message := '<RAW_MATERIAL>'||
                     '<BAR_CODE>10000764601</BAR_CODE>'||
                     '<MATERIAL>1101448</MATERIAL>'||
                     '<VENDOR_CODE/>'||
                     '<PRODUCTION_DATE>0000-00-00</PRODUCTION_DATE>'||
                     '<EXPIRE_DATE>0000-00-00</EXPIRE_DATE>'||
                     '<BATCH/>'||
                     '<PO_NUM/>'||
                     '<MATERIAL_DESCRIPTION>POWER SUPPLY</MATERIAL_DESCRIPTION>'||
                     '<SPEC_NAME/>'||
                     '<STOCK_CODE>BSW-JH</STOCK_CODE>'||
                     '<INSPECTION_LOT>00</INSPECTION_LOT>'||
                     '<USAGE_DECISION_CODE/>'||
                     '<MATERIAL_GROUP>031</MATERIAL_GROUP>'||
                     '</RAW_MATERIAL>';
          dbms_output.put_line('XML '||xml_message);
    --      vp_interface.load_rawmat@cnprpt1_pds(SYSDATE, destination_system,
    --                   xml_message, p_ret);
          vp_interface.load_rawmat(SYSDATE, destination_system,
                       xml_message, p_ret);
          dbms_output.put_line('Return Code '||p_ret);
          COMMIT;
    EXCEPTION
      WHEN OTHERS THEN
        status_code := SQLCODE;
        status_message := SUBSTR(SQLERRM, 1, 64);
    --    Extract_Error_Logger(proc_name, 'LOCAL', SYSDATE, -999,
    --                         status_message, 0, debug_message);
        ROLLBACK;
    END send_rm;
    And while i am calling this Store procedure in MII, I am facing error.
    I have tried different ways but didnt solved
    In SQL Query, i kept mode as: FixedQueryOutput
    Can anyone tell me or send code for calling above store procedure
    And onemore thing, While creating store procedure in Oracle for MII. Do we need to Create output parameter as cursor or normal.  
    Thanks,
    Kind Regards,
    Praveen Reddy M

    Hi Praveen
    Our wrapper was created because we could not modify the procedure we call (it was not returning a cursor).
    CREATE OR REPLACE PROCEDURE CHECK_PUT_IN_USE
    (STRCMPNAME in varchar2,
    STRSCANLABEL in varchar2,
    RCT1 out SYS_REFCURSOR
    AS
      charDispo          Char(1);
      charStatus          Char(1);
      intCatNo          Integer;
      charCatDispo     Char(1);
      strCatQual          VarChar2(2);
      strCatDesc          VarChar2(30);
      strMsg          VarChar2(128);
    BEGIN
    qa.check_put_in_use@AR(STRCMPNAME,
                                              STRSCANLABEL,
                                              charDispo,
                                              charStatus,
                                              intCatNo,
                                              charCatDispo,
                                              strCatQual,
                                              strCatDesc,
                                              strMsg);
    OPEN RCT1
    FOR Select charDispo,charStatus,charDispo,charStatus,intCatNo,charCatDispo,strCatQual,strCatDesc,strMsg from Dual;
    END;
    Hope this helps
    Regards
    Amrik
    then with a FixedQueryWithOutput
    call mixar.qasap.wrapper_update_put_in_use('[Param.1]','[Param.2]',[Param.3],?)
    Hope this helps.

  • Oracle Instant Client and OUT Parameter of custom type in Stored Procedures

    Hi @ all!
    I try to set up a simple client application, that calls a stored procedure via Instant Client from C#.
    The stored procedure and assiciated types looks like this:
    TYPE MYVALUE AS OBJECT
          Id      INTEGER,
          value     FLOAT
    TYPE MYVALUELIST AS TABLE OF MYVALUE;
    PROCEDURE ReadValues( ID IN INTEGER,
                                        RESULTSET OUT MYVALUELIST)
                                           IS
    ...I created an Oracle Command executing this SP and added OracleParameters for ID and (where I got stuck) the RESULTSET.
    Is it possible to pass a parameter with a custom type from C# in some way?
    I already tried it as a function with SELECT * FROM TABLE(ReadValues(1));
    With my parameter RESULTSET as the RETURN type. But since I use DML within the procedure, this does not work inside of a query...
    Any suggestions?
    Thanks in advance!

    Hi Greg!
    Sorry, I misunderstood the forum topic then. =(
    Anyway, in the example you provided in the link, this is nearly exactly my situation. But there the Oracle.DataAccess.Client is used, where the OracleDBType can be called to initialize an object of type person. I use the instant client libraries called by using System.Data.OracleClient. There is only the OracleType enum, that does not contain an object or something similar.
    So I do it right now after trying a bit with a ref cursor parameter and an OracleDataAdapter - the ref cursor is passed back from Oracle as a DataReader, so die DataAdapter is able to use it for a .Fill():
    OracleCommand cmd = new OracleCommand();
    cmd.Parameters.Add("RESULTSET", OracleType.Cursor).Direction = ParameterDirection.Output;
    OracleDataAdapter odr = new OracleDataAdapter(cmd);
    DataTable result = new DataTable();
    odr.Fill(result);Within my stored procedure I just added the following OUT parameter:
    PROCEDURE ReadValues( ID IN INTEGER,
                                        RESULTSET OUT sys_refcursor)
                                           IS
    currentlist MYVALUELIST;
    ... [Adding elements to that list] ...
    OPEN resultset for select * from TABLE(currentlist);It works now, but I don't like that solution that much since I'm always afraid that there are lots of opened cursors idyling around. Do I have to close this one explicitly after filling my table by the DataAdapter?
    Regards

  • Getting Xml  tag values  based on procedure in  parameter

    Hi,
    I have an XML file like bellow
    <college>
    <studenthistory>
    <sno>100</sno>
    <sname>jeff</sname>
    <sdept>comp</sdept>
    </studenthistory>
    <studenthistory>
    <sno>200</sno>
    <sname>kelly</sname>
    <sdept>physics</sdept>
    </studenthistory>
    </college>
    i am writing a procedure like bellow
    create or replace procedure p_test(studendtno number)as
    val1 varcahr2(200);
    val1 varcahr2(200);
    xml_file sys.xmltype;
    begin
    xml_file:= XMLType(bfilename(testdirectory, 'test.xml'),
    nls_charset_id('AL32UTF8'));
    end;
    i am able to get xml file from rempote to xml_file variable...
    Now what i want is if i send 100 as in parameter just i want 100 related ename,edept values ,if i send 200 as in parameter i want 200 related values ename,edept.
    output
    val1 val2
    jeff comp
    kelly physics
    Thanks
    satya
    Message was edited by:
    satya81
    Message was edited by:
    satya81
    Message was edited by:
    satya81
    Message was edited by:
    satya81

    How about something like
    SQL> create or replace procedure p_test (studendtno number, cur out sys_refcursor)
    as
    begin
       open cur for
          with xml_tab as
               (select xmltype
                          ('<college>
                              <studenthistory>
                              <sno>100</sno>
                              <sname>jeff</sname>
                              <sdept>comp</sdept>
                              </studenthistory>
                              <studenthistory>
                              <sno>200</sno>
                              <sname>kelly</sname>
                              <sdept>physics</sdept>
                              </studenthistory>
                             </college>') xml
                  from dual)
          select t.column_value.extract ('studenthistory/sname/text()').getstringval() sname,
                 t.column_value.extract ('studenthistory/sdept/text()').getstringval() sdept
            from xml_tab x,
                 table (xmlsequence (x.xml.extract ('college/studenthistory'))) t
           where t.column_value.extract ('studenthistory/sno/text()').getnumberval() = studendtno;
    end p_test;
    Procedure created.
    SQL> var cur refcursor
    SQL> exec   p_test(100,:cur)
    PL/SQL procedure successfully completed.
    SQL> print cur
    SNAME                          SDEPT                        
    jeff                           comp                         
    1 row selected.

  • Passing quotation mark in parameter

    Hi,
    I have one query which I migrated from sql server database. It is given below. I am passing single quote mark as a parameter to this query but it always retrieves 0 as count. But I have 1 record in table. As a solution to this I have resolved this issue for sql server by passing two quotation mark (replacing single quotation mark with double quotation mark). This same solution applies here too. when I pass any parameter with single quote in it, it will replace single quote with double quote and then pass it to the below given procedure. But still it is not working correctly. I have similar query for retrieving that record and it is working fine. Any idea why the below query is not working correctly?
    PROCEDURE GetEntUserGroupCountWithOther
    ppGroupName IN VARCHAR2 DEFAULT '%' ,
    cp1 IN OUT SYS_REFCURSOR
    AS
    BEGIN
    OPEN cp1 FOR
    SELECT COUNT(*) TotalRecords
    FROM ( SELECT Id EnterpriseUserGroupId,
    Name NAME,
    Description DESCRIPTION,
    IsDefault
    FROM EnterpriseUserGroup ) T1
    WHERE UPPER(NAME) LIKE +UPPER('%' || ppGroupName || '%');
    END;
    Thanks,
    Edited by: user10768079 on Jul 14, 2009 10:56 PM

    not sure what your question is, seems to work
    create table EnterpriseUserGroup
    (name varchar2(10))
    insert into EnterpriseUserGroup values ('Hello');
    insert into EnterpriseUserGroup values ('World');
    insert into EnterpriseUserGroup values ('''');
    commit;
    create or replace
    PROCEDURE GetEntUserGroupCountWithOther
    (ppGroupName IN VARCHAR2 DEFAULT '%'
    ,cp1 IN OUT SYS_REFCURSOR
    AS
    BEGIN
       OPEN cp1 FOR
          SELECT COUNT(*) TotalRecords
            FROM EnterpriseUserGroup T1
           WHERE UPPER(NAME) LIKE UPPER('%' || ppGroupName || '%');
    end;
    /and to test it
    SQL> var rc refcursor
    SQL>
    SQL>
    SQL> begin
      2     GetEntUserGroupCountWithOther ('''', :rc);
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SQL> print
    TOTALRECORDS
               1
    SQL> begin
      2     GetEntUserGroupCountWithOther ('hello',  :rc);
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SQL> print
    TOTALRECORDS
               1
    SQL> begin
      2     GetEntUserGroupCountWithOther ('not there',  :rc);
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SQL> print
    TOTALRECORDS
               0

Maybe you are looking for

  • My ipod nano 3rd gen gets error code -9459 when I try to convert a video in Itunes

    I'm tring to convert video from Youtube to play on my ipod nano 3rd gen.  When i go to itunes and Advanced and set it to convert for ipod it goes on for quite a while then about 3/4 way done I get error message Erroe occurred converting file "teapot

  • Can't print on my HP OfficeJet Pro 8500/910

    I have had my PC and printer connected wirelessly for years without a problem.  I recently moved, and Comcast installed a new modem with a built in router.  I wasn't getting a good signal throughout the house, so i hooked up my original router, as we

  • Execution date in a query

    Hello all, Is there any way to use sy-datum or something like that to store execution date of a query? Thanks in advance Carmen

  • Special character handling in XI

    Hi, I have a scenario wherein edifact files are passed through XI to partners . The edifact input file contains special characters like ô which gets converted to Ã.This is causing the despatch advice to fail at the receiver end. Can anyone suggest ho

  • Connecting to multi databases from Oracle Forms

    I am trying to connect to 2 databases from my form. The primary connection is to a datbase where reports information(i.e. Report name,parameters) is saved. When the form runs and user picks a report to run, i want to change connection to a different