Difference of cursor (REF Cursor & Sys_Refcursor)

Hello

Is there a difference between REF Cursor and SYS_Refcursor?

I see some packages using sys_refcursor and others using the REF Cursor.
Package 1 (Spec):
   PROCEDURE s_demo1 (
      ret_rset   OUT      sys_refcursor
   );


Package 2 (Spec):
TYPE cur_set IS REF CURSOR;
PROCEDURE s_test1 (out_data OUT cur_set);
PROCEDURE s_test2 (out_data OUT cur_set);
I'm going through this link (http://sql-plsql.blogspot.com/2007/05/oracle-plsql-ref-cursors.html) but did not find the answer.

SYS_REFCURSOR is a REF CURSOR defined by oracle. Thus, you can not compare SYS_REFCURSOR and REF CURSOR.

SYS_REFCURSOR is a week REF CURSOR, meaning it doesn't have a return type precise than what we will have in a refcursor defined by the user.

And in your example, I see no difference between SYS_REFCURSOR and CUR_SET because only the two week REF CURSOR.

Published by: Karthick_Arp on November 17, 2010 06:36

Tags: Database

Similar Questions

  • What is the difference between the ref cursor and the sys_refcursor.

    create or replace procedure GetEmployeesInDept (c sys_refcursor)

    Hello


    I have a query related to the above stored procedures.
    When you set the cursor, we mentioned as sys_refcursor and in some US sites I saw him as a REF CURSOR as shown

    create or replace procedure GetEmployeesInDept (Ref Cursor c)


    Please tell me what is the difference between the ref cursor and the sys_refcursor.

    http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14261/tuning.htm#sthref2376

    Concerning

    Etbin

  • Need the difference between strong Ref Cursor and weak Ref Cursor examples

    Oracle 9.2

    It would be great if someone can help understand the differences between
    1 Strong Ref Cursors(return type)
    and
    2. weak Ref Cursor (no return type)

    What I read is weak ref Cursor as sys_refcursor is better to use the ref Cursor, because in the case of slider strong Ref object type that will be returned must be declared in advance. It dosent make sense to me?

    I start with the examples would be appreciate for advice

    Strong Ref Cursor

    create the package str_pack
    is
    type sref_type is ref cursor return emp % rowtype;
    SVAR sref_type;
    end str_pack;

    Create procedure st_proc (eid in number, c1 on str_pack.sref_type)
    is
    Start
    Open c1 to select empno, ename, sal from emp where empno = eid;
    end;

    declare
    str_pack.sref_type C1;
    type rec is RECORD (eid, ename varchar2 number (20), number of sal);
    SheikYerbouti rec;
    Start
    st_proc(10,C1);
    loop
    When exit c1% notfound;
    Fetch c1 into SheikYerbouti.
    end loop;
    Close c1;
    end;


    There could be errors in the above example but its basically to get a better understanding.

    For weak Ref Cursor

    procedure of the child

    Create procedure child_proc (in number, c1 on sys_refcursor eid)
    is
    Start
    Open c1 to select empno, ename, sal from emp where empno = eid;
    end;

    parent process

    Create procedure parent_proc (recnum varchar2)
    is
    p_retcur sys_refcursor;
    emp_row emp % rowtype;
    Start
    child_proc (eid, p_retcur);
    loop
    extract the p_retcur in emp_row;
    dbms_output.put_line(emp_row.empno ||) e '|| emp_row. Ename | "wins". emp_row. SAL);
    end loop;
    end parent_proc;

    Concerning
    @

    Hello

    the fundamental difference is to do with the compiling and linking of runtime type that occurs.

    The he should explain a lot more detail than I could ever!
    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:1640161160708

    P;

  • sys_refcursor and Ref Cursor

    Hello

    I found this diffrence between ref and sys_refcursor slider.

    If you specify return_type, then the variables of type and slider REF CURSOR of this type are strong; If not,
    they are weak.
    The variables SYS_REFCURSOR and slider of this type are weak.

    my situation is that I must write a procedure stored so many reports entery pages. little enter pages use typed data groups and can't.

    so please tel me what is the best in terms of performance and maintainability above three conditions?

    Yours sincerely

    944768 wrote:

    my situation is that I must write a procedure stored so many reports entery pages. little enter pages use typed data groups and can't.

    Called stored procedures what and where?

    If, with a layer of app such as Java or .net, then they do not distinguish between weak and strong ref Cursor - because it is a concept of PL/SQL.

    And by using a ref cursor type in PL/SQL is intended to provide a mechanism to pass the handle of real cursor SQL cursor created in this session, the client (for example Java or .net). Nothing more. So, why even care that PL/SQL? a weak or strong Ref to the application layer slider

    so please tel me what is the best in terms of performance and maintainability above three conditions?

    I find always frustrating that there is this concept that some methods to create cursors, results in faster and better than other methods, the sliders. It is a concept of bs. All SQLs are analyzed as a SQL cursors. Each. Unique. One. By the SAME CBO.

    If the client code (Java, PL/SQL or other) you write for this SQL cursor DOES NOT change the source SQL.

    This therefore does not cause the CBO now compile a different SQL execution plan for her. The CBO does not care if your code uses a strong Ref Cursor or a weak Ref Cursor, or a slider DBMS_SQL, an explicit cursor, or whatever. Those are concepts of customer. And do not change the execution plan of cursor SQL on the server. Or its planned performance/cost.

    Yes, your client code (Java, PL/SQL, etc.) can use the SQL cursor on the server-side evil - and this can affect performance.

    But waiting for a weak Ref cursor will somehow cause a faster cursor or slower for the same SQL statement, that a strong Ref cursor is not understanding what SQL cursor is, and how the customer interacts with its data types, the classes of customers and its customer interfaces with this SQL cursor.

  • Cursor of return of (nested) function - PLS-00201: identifier of the CURSOR must be declared

    Hello

    I have a function in which I use nested functions (because I don't want to create objects explicit / external, it is a requirement that I don't have any effect on / I don't want to change).

    In my external function, I use cursor by declaring them in IS-section and then open using the loop for instruction.

    In my inner function / nested, I also want to use a cursor.

    There I also said one like I did in an external function within the section IS of the nested function.

    SQL Developer complains about syntax error (';: wait ").

    When you try to compile the whole process I get the following error:

    "Error (97,14): PLS-00201: identifier 'CURSOR' must be declared '.

    It's my external function starts as:

    CREATE OR REPLACE FUNCTION FN_GENERATE_QUERY_PMT (instance_id_in IN NUMBER, language_in IN VARCHAR2)
    RETURN CLOB
    IS
         CURSOR c_outer IS
          SELECT * FROM BLA;
    

    When it comes to my internal function with the section IS of the external function and stands (inner functions should be at the end of the Section IS to stand behind the statements of variable and cursor, otherwise there will be an error):

    FUNCTION nfn_get_value (num_in IN NUMBER)
          RETURN SYS_REFCURSOR
        IS
          SYS_REFCURSOR c_inner IS
          SELECT *
          FROM BLUB;
        BEGIN
          RETURN c_where_in;
        END;
    

    After that there will be another nested function, then the BEGIN section will appear.

    When looking for 'function returns cursor' I can only find solutions where the cursor is declared in section IS (sometimes its an AS-section o_O * worried *) but wihtoug select, just declare type.

    The cursor focus is added in the Begin block to the way open for instruction. But I don't want to open it yet. I want to open the cursor using the loop statement. I am able to reopen? used can it be two sliders while one will not be closed properly?

    How to fix to return a cursor that I can use in my external function.

    Advice would be appreciated.

    Thanks in advance.

    Maybe I got the soultion
    First of all, I found this thread:

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:5241391331097

    said the following:

    2) a ref cursor is just a cursor.  a ref cursor is just a cursor.  a ref cursor is just a cursor.... (keep saying it over and over
    

    But fortuneately I also found this post:
    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:14188501024541

    where thankfully someone shared her knowledge with others:

    In view of this block of code - you may see more "prominent" unlike - any

    How many times you run this block - cursor C will always be select * twice.  The ref

    cursor is not guaranteed.

    Another difference is that a ref cursor can be returned to a client.  a plsql 'cursor cursor.

    cannot be returned to a client.

    Another difference is a cursor can be global - a ref cursor cannot (you cannot set

    them outside a procedure / function)

    Another difference is a ref cursor can be passed to the subroutine - a subroutine

    cursor cannot be.

    This explains why the samples seem always fair with open (Ref) cursor within the section to START.

    I expeceted this (as I wrote in the first post) and ask if the course of opening will be sent back twice or just redirect. I suppose it it reassigns who were just a little in performance.

    But I can't yet find this good explanation of this type anywhere within the documentation and of course I didn't read it all. Shame on me, but I'm always engaged by internet download.

    I would be grateful if someone could say my last statement and leave a comment on double-distribution of the refcursors has reopened.

    Thanks in advance.

  • opening and extraction of cursor... what accually is happening?

    So, if we have an explicit cursor... us open with open... c_cursor_name and it retrieves in a variable...
    My question is - what happens really when we open the cursor?

    is Oracle a single instance of the object cursor in memory? or... is it reads some data base on the lines that will be extracted (rowid?).. ? or what?

    In addition, if we do an insert into a table that will be deployed by the cursor (while the cursor is go get..), slider label these new data? for example, what difference if cursor onto an indexed ID and we do an insert with an ID = 10, and the cursor is currently on ID = 100? or vice versa? (commit included in the instructions)...

    Oh, so many questions :)
    TNX :)

    user9158455 wrote:
    TNX a lot :)

    Thus, when the cursor creates the execution plan, it reads (extractions) data because it is the current SNA, or last write coherent?

    The CHN is the marker which it uses to ensure the coherence of reading and ignore subsequent insertions/deletions etc. of other sessions.

  • Warehouse Builder problem (deploy - package - mapping)

    Hello

    I have a problem with OWB.

    We have both development and Test environments, and deploy us a mapping (including all objects) but when we generated the code we have a difference:

    Develpoment:

    CURSOR 'AGGREGATOR_c' IS
    SELECT 'AGGREGATOR '. ' ' CONTEO_RANGOS ' 'CONTEO_RANGOS '.
    + (SELECT COUNT ("AGG_INPUT". "RANGO_CD") "CONTEO_RANGOS" + "
    + (SELECT "TABLE_NAME". ' ' RANGO_CD ' 'RANGO_CD ' +.
    + "SCHEMA." "' TABLE_NAME ' 'TABLE_NAME ' +.
    + WHERE (EXISTS (SELECT 1 +))

    + FOR (SELECT MAX ("TABLE_NAME". "ACTUALIZACION_REGISTRO_DT") "FECHA_ACT_MAX" + "
    +                                                  FROM "SCHEMA"." TABLE_NAME' 'TABLE_NAME') 'AGGREGATOR_0 ' +.

    + WHERE ("AGGREGATOR_0". "" FECHA_ACT_MAX "="TABLE_NAME ". ("' ACTUALIZACION_REGISTRO_DT").

    +                                        )+
    +                              )+
    +                    )+
    + "AGG_INPUT") "AGGREGATOR." +

    Test:

    CURSOR 'AGGREGATOR_c' IS
    SELECT 'AGGREGATOR '. ' ' CONTEO_RANGOS ' 'CONTEO_RANGOS '.
    + (SELECT COUNT ("AGG_INPUT". "RANGO_CD") "CONTEO_RANGOS" + "
    + (SELECT "TABLE_NAME". ' ' RANGO_CD ' 'RANGO_CD ' +.
    + 'TABLE_NAME', 'TABLE_NAME ' +.
    + WHERE (IT EXISTS (SELECT 1 FROM (SELECT MAX ("TABLE_NAME".) "ACTUALIZACION_REGISTRO_DT") "FECHA_ACT_MAX" + "
    + 'TABLE_NAME', 'TABLE_NAME') 'AGGREGATOR_0 ' +.
    + WHERE ("AGGREGATOR_0". "" FECHA_ACT_MAX "="TABLE_NAME ". ("' ACTUALIZACION_REGISTRO_DT").

    +                                             )+
    +                                   )+

    +                         )+

    + "AGG_INPUT") "AGGREGATOR." +


    We have no idea how manufacturer warehouse set the schema of the table database...

    Any suggestion?

    Thank you!

    Kind regards
    Diego.

    OWB will not format shema.table_name use if the table is in the same module in that your mapping is. If you want to "" use this format that you define in the mapping setup--> tables--> and on the table, you set the SHEMA parameter. Now when you generate the code OWB does precede the table with schema name.

  • ORA-00904: "I." "" PROCESS_FLAG ": invalid identifier - I is a var slider

    create or replace PROCEDURE validate_data_proc
    IS

    CURSOR c1
    IS
    SELECT itemname, ICT, msib mtl_system_items_b item_conv_tab_sv itemname1 msib.segment1 icts.item_name
    where icts.item_name! = msib.segment1;
    CURSOR c2
    IS
    SELECT TIC. Nom_element itemname, icts.ORGANIZATION_ID org, msib.segment1 itemname1, msib.organization_id the item_conv_tab_sv ICT, msib mtl_system_items_b org1
    where icts.organization_id = msib.organization_id and icts.item_name! = msib.segment1;

    BEGIN

    I'm IN c1
    LOOP
    -Select i.item_name from i in
    If (c1% notfound) then
    FOR r IN c2
    LOOP
    If (c2% notfound) then

    update of HCCI process_flag = 3 set item_conv_tab_sv where item_conv_tab_sv.item_name = r.item_name;
    on the other

    update of item_conv_tab_sv HCCI set process_flag = 1 where item_conv_tab_sv.item_name = r.item_name;
    end if;
    end loop;
    on the other
    update of HCCI process_flag = 3 set item_conv_tab_sv where item_conv_tab_sv.item_name = i.item_name;
    end if;
    COMMIT;
    end loop;




    END validate_data_proc;


    I use a cursor nested which I create that err
    I get the foll error message,

    Error (23.30): PL/SQL: statement ignored
    Error (23,116): PL/SQL: ORA-00904: 'R '. "" Nom_element ": invalid identifier
    Error (23,118): PLS-00302: component 'Nom_élément' must be declared
    Error (26,32): PL/SQL: statement ignored
    Error (26,109): PL/SQL: ORA-00904: 'R '. "" PROCESS_FLAG ": invalid identifier
    Error (26,111): PLS-00302: component 'PROCESS_FLAG' must be declared
    Error (30,31): PL/SQL: statement ignored
    Error (30,108): PL/SQL: ORA-00904: "I." "" PROCESS_FLAG ": invalid identifier
    Error (30,110): PLS-00302: component 'PROCESS_FLAG' must be declared
    Error (26,118): PL/SQL: ORA-00904: 'R '. "" Nom_element ": invalid identifier
    Error (26,120): PLS-00302: component 'Nom_élément' must be declared
    Error (30,117): PL/SQL: ORA-00904: "I." "" Nom_element ": invalid identifier
    Error (30,119): PLS-00302: component 'Nom_élément' must be declared


    someone... Help, please...

    Find a difference:

    CURSOR c1
    IS
    SELECT icts.item_name itemname , msib.segment1 itemname1 of the item_conv_tab_sv ICT, mtl_system_items_b msib
    where icts.item_name! = msib.segment1;
    CURSOR c2
    IS
    SELECT TIC. Nom_element itemname, icts.ORGANIZATION_ID org, msib.segment1 itemname1, msib.organization_id item_conv_tab_sv cts, mtl_system_items_b msib org1
    where icts.organization_id = msib.organization_id and icts.item_name! = msib.segment1;

    And:

    update of HCCI process_flag = 3 set item_conv_tab_sv where item_conv_tab_sv.item_name = rnom_element;
    Update item_conv_tab_sv set process_flag icss = 3 where item_conv_tab_sv.item_name = i.nom_element;

    But even in this case, your code is wrong for CURSOR loop retrieves a line and stops automatically when there is no lines. Therefore, there is no sense to check notfound % c1 inside the loop for the SLIDER - this will be always FALSE. If your interior for CURSOR LOOP (C2) will never run.

    SY.

  • How can I delete windows firewall settings

    I think I discovered why IE 8 is not letting the search engines work and only the address bar and work favorites. Firewall blocking the search engines. How should I do?

    Hello

    Do you receive error messages related to the firewall when you try to access the Web sites?

    Temporarily disable the firewall and see if it makes a difference.

    Refer to this article for help:
    http://support.Microsoft.com/kb/283673


    NOTE:
    please check activate you to re - the Windows Firewall.

    For your reference:

    Troubleshooting settings of Windows Firewall in Windows XP Service Pack 2 for advanced users
    http://support.Microsoft.com/kb/875357

    Kind regards
    Afzal Taher
    Microsoft technical support engineer

  • Why stop and start my videos online constantly?

    Why stop and start my videos online constantly? I try to watch something and she leaves and I get the "loading" symbol but it works only for a few seconds and then shuts down to 'load' again!

    Hello

    I suggest you to uninstall and reinstall Adobe Flash Player on your
    computer and check if it makes a difference.

    Refer to this article for help:
    http://kb2.Adobe.com/CPS/141/tn_14157.html

    Download the latest version of Flash Player from this link:
    http://www.Adobe.com/support/flashplayer/downloads.html

  • All of a sudden, when I use the column scroll it moves by 1/2 second intervals where it was liquid before. I did something to slow this thing? Thank you

    This action occurs in any screen in any program.  Sometimes with vertical and horizontal scrolling columns.  Thank you, Julie

    Hello

    Follow these steps:


    Step 1
    : update the drivers for your mouse and check if it makes a difference.

    Refer to this article for help:
    http://Windows.Microsoft.com/en-us/Windows-Vista/update-a-driver-for-hardware-that-isn ' t-work correctly


    Step 2
    : perform a clean boot to verify if a third-party program or service that is running in the background is the cause of the problem.

    Refer to this article for help:


    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7
    http://support.Microsoft.com/kb/929135


    Note:
    please check that you put your computer to normal startup mode after completing the troubleshooting steps. Steps are available in the article above.

  • Error: 0x8007000D: the data are incorrect on renaming a folder

    Hi, I am Nader... I have this problem recently when I come to rename a folder, it throws the error "error: 0x8007000D: these data are incorrect. Just at the moment where I click on try key it shows works. If it works, is a little annoying. Would appreciate some help here.

    NSK

    HI naderskhan,

    The problem occurs only with certain folders or all folders?

    Perform these steps and check if it solves the problem:

    Step 1:

    I suggest to create a new user account and check if it makes a difference.

    Refer to this link for help:
    http://Windows.Microsoft.com/en-us/Windows7/create-a-user-account

    If it solves the problem, you can fix the damaged user profile.

    See this link:
    http://Windows.Microsoft.com/en-us/Windows7/fix-a-corrupted-user-profile

    Step 2:

    Perform a clean boot to verify if a third-party program or service is the cause of the problem.

    Refer to this article for more information:

    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7
     http://support.Microsoft.com/kb/929135

    Steps to perform a clean boot:
    a. click the ORB start on your desktop
    b. type msconfig in the search box and press ENTER.
    If you are prompted for an administrator password or a confirmation, type the password, or click on continue.
    c. in the general tab, click Selective startup.
    d. under Selective startup, clear the check box load startup items.
    e. click on the Services tab, select the hide all Microsoft Services check box and then click Disable all.
    f. click OK.
    g. When prompted, click on restart.

    NOTE: Please check that you start the computer in normal mode after a repair. Follow step 7 of article.

    Kind regards
    Afzal Taher-Microsoft Support.
    Visit ourMicrosoft answers feedback Forum and let us know what you think.

  • Screen goes black randomly while the computer is in use

    Original title: black screen, bursts short
    I have a new computer with Windows 7, I also have a LG FLATRON F700b MONITOR, I get some black screens with nothing, they had a split second and a quick acceleration of music they occur 5, 6, 7, 8 times in one minute, it does not affect type me, like now, I do not lose keystrokes. It happens from the moment I start with the screen saver, the machine is a not to be logged on to Windows or Internet, eventually becomes less a problem when the screen and M/c for awhile, but never seems to completely disappear. What I want to know is there anything else he can be cured by buying a new monitor? any info would be greatly appreciated

    Hello

    1. you hear the music when the blackscreen appears?
    2. did you last changes made before the problem started?
    3. have you installed any third-party screen saver?

    Try the following steps:

    Step 1: disable screen saver and check if it makes a difference.

    Refer to this link for help:
    Enable or disable the screen saver

    Step 2: update the drivers for your graphics card.

    Follow these steps to update the drivers manually:
    a. open the Manager of devices by clicking the Start button, click Control Panel, click System and security, and then, under system, clicking Device Manager. If you are prompted for an administrator password or a confirmation, type the password or provide confirmation.
    b. in the list of hardware categories, click on the graphics card and then double-click the device name.
    c. click on the driver tab, click Update driver and then follow the instructions. If you are prompted for an administrator password or a confirmation, type the password or provide
    confirmation.

    Reference:
    http://Windows.Microsoft.com/en-us/Windows7/update-a-driver-for-hardware-that-isn ' t-work correctly

    Kind regards
    Afzal Taher - Microsoft technical support.
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • REP-0737: must be a function of return type 'ref cursor.

    Hi all

    I have create a ref cursor query in reports 10 g. But it is giving error REP-0737: must be a function of return type 'ref cursor.

    Here is my code

    function QR_1RefCurDS return sys_refcursor is
    
     My_Cur Sys_Refcursor;
    begin
      Open My_Cur for select * from scott.emp order by deptno;
      return My_Cur
    end;
    

    fate of the screen.

    Ref_Cursor_in_reports10g.jpg

    Oracle Forms/Reports has a complete PL/SQL engine and (only) the SQL parser.

    However, the engine of forms/States PL / SQL and SQL Analyzer are at a level that was in the Oracle 8.0 database.

    So, in the forms/States functions/procedures and forms/States triggers, you can not use SQL commands that did not exist in the 8.0 database.

    The predefined SYS_REFCURSOR type is introduced in Oracle 9i.

    Use this:

    PACKAGE test_rc IS

    TYPE of rc_type IS REF CURSOR RETURN emp % ROWTYPE;

    END;

    FUNCTION RETURN QR_1RefCurDS Test_rc.rc_type IS

    test_rc.rc_type RC;

    BEGIN

    OPEN the RC to SELECT * FROM emp;

    RETURN rc;

    END;

    Kind regards

    Zlatko

  • Ref Cursor remote procedure fails

    Remote database server Oracle 9iR2 1

    Local database server Oracle 10 g 2 2

    Remote procedure:

    CREATE OR REPLACE PROCEDURE p_get_results (   i_query   IN   VARCHAR2
                                                , o_refc    OUT  sys_refcursor
                                              )
    AS
    BEGIN
        IF ( i_query IS NULL )
        THEN
             RAISE_APPLICATION_ERROR(-20001,'The paramter i_query cannot be null') ;
        END IF ;
    
    
        OPEN o_refc FOR i_query ;
        
        EXCEPTION
            WHEN   others   THEN
                 RAISE ;
    END p_get_results ;
    /
    
    

    Local PL/SQL block

    SQL> var i_query varchar2(100)
    SQL> var o_refc refcursor
    SQL> exec :i_query := 'select count(*) from oo_attrs'
    
    
    SQL> exec p_get_results@demo_oo2 (:i_query,:o_refc)
    
    
    ERROR at line 1:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-01001: invalid cursor
    
    

    Check the link works and request db:

    SQL> select count(*) from oo_attrs@demo_oo2;
    
      COUNT(*)
    ----------
           225
    

    Am I missing something here?

    Am I missing something here?

    Yes - you cannot use REF CURSOR over links to db.

Maybe you are looking for