Packages and poorly Ref Cursor

SQL Server Developer, I fight with Oracle to say the least. I fought with the poor performance of the extraction of data from the database, but also a multitude of other things. The last number I have is a stored procedure in a package that does not work when run from my .NET code. I have many other packages and stored procedures that are working, but this one is a failure. I don't get any errors, just no data when I should be.

I would run the toad package and see if it is the stored Proc and packaging, or if there is a problem in my .NET code. My stored procedure accepts a single PARAMETER of type integer, and has two parameters SYS_RefCursor OUT. My SQL uses the parameter (ID field) to select from a table. If I run the select SQL by itself with the hardcoded value ID, it works fine. I can run too where it uses the SQL for open cursors and inserts the data but I can't determine if it worked.

So, my questions are the following:

Can I select a Ref_Cursor? I'm trying to do something like that.
results_cursor SYS_REFCURSOR;

OPEN results_cursor FOR
   SELECT * FROM Person;

SELECT * FROM results_cursor;
If I could get the 1st issue a response, I can keep up with my next question.

Thanks in advance.
Jeff

Hello

I don't see an issue of .NET at this point, so you can have the best chance to post in the forum PLSQL, as it seems that if you need help writing a procedure, rather than interacting with a procedure well known in .NET:
SQL and PL/SQL

I'm not clear on your question though. Yes, you can read from a slider ref, and you do it by getting him.

SQL > set serveroutput on

SQL > declare
Ref1 2 sys_refcursor;
3 rec1 emp % rowtype;
Number 4 NTC;
5. start
6. open ref1 for select * from emp;
7 LOOP
8 FETCH INTO rec1 ref1;
9 OUTPUT WHEN ref1% NOTFOUND;
10 DBMS_OUTPUT. Put_line (' name = ' | rec1.ename);
11 END OF LOOP;
12 end;
13.
Name = SMITH
Name = ALLEN
Name = WARD
Name = JONES
Name = MARTIN
Name = BLAKE
Name = CLARK
Name = SCOTT
Name = KING
Name = TURNER
Name = ADAMS
Name = JAMES
Name = FORD
Name = MILLER

PL/SQL procedure successfully completed.

SQL >

Maybe if clarify what you are trying to do or accomplish in "selecting from a ref cursor" it would be useful.

Greg

Tags: Database

Similar Questions

  • Apex and accept Ref Cursor?

    Apex and accept Ref Cursor?

    Apex and accept objects?

    can someone help me please.

    Hi Nani4850,

    Nani4850 wrote:

    Apex and accept Ref Cursor?

    Apex and accept objects?

    The language of business for APEX is PL/SQL, so yes you can use REF CURSOR and pass objects to you packaged functions/procedures.

    How does this relate to Oracle APEX?

    Please explain what you plan to use a REF CURSOR in the APEX.

    Kind regards

    Kiran

  • differnce between Ref Cursor strong and weak Ref Cursor

    differnce between Ref Cursor strong and weak Ref Cursor

    SQL and PL/SQL FAQ

    -------------
    Sybrand Bakker
    Senior Oracle DBA

  • 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;

  • How to run the packaged procedure with Ref Cursor

    Hello.
    The question may be very simple for you... but I was confused how to run
    I have the following package
    CREATE OR REPLACE PACKAGE CURSPKG AS 
        TYPE T_CURSOR IS REF CURSOR; 
        PROCEDURE OPEN_ONE_CURSOR (N_EMPNO IN NUMBER, 
                                   IO_CURSOR IN OUT T_CURSOR); 
        
    END CURSPKG;
    / 
    
    
    CREATE OR REPLACE PACKAGE BODY CURSPKG AS
        PROCEDURE OPEN_ONE_CURSOR (N_EMPNO IN NUMBER,
                                   IO_CURSOR IN OUT T_CURSOR)
        IS 
            V_CURSOR T_CURSOR; 
        BEGIN 
            IF N_EMPNO <> 0 
            THEN
                 OPEN V_CURSOR FOR 
                 SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME 
                      FROM EMP, DEPT 
                      WHERE EMP.DEPTNO = DEPT.DEPTNO 
                      AND EMP.EMPNO = N_EMPNO;
    
            ELSE 
                 OPEN V_CURSOR FOR 
                 SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME 
                      FROM EMP, DEPT 
                      WHERE EMP.DEPTNO = DEPT.DEPTNO;
    
            END IF;
            IO_CURSOR := V_CURSOR; 
        END OPEN_ONE_CURSOR; 
    
        
    END CURSPKG;
    /
    But I want to test (run) this procedure...
    But confused how to have Ref Cursor
    Could you help me in this...

    Thank you

    You must declare a variable of type T_CURSOR and pass it to the procedure like this.

    declare
      lOutCursor CURSPKG.T_CURSOR;
    begin
      CURSPKG.OPEN_ONE_CURSOR(, lOutCursor);
    end;
    
  • Reg. Converting a package in a Ref cursor level slider

    Hi guru,.

    I need to convert a package-level slider which contains the clause 'FOR UPDATE OF' in a Ref cursor when the query will be dynamically built with the necessary table name and other settings.

    Using this slider many Update statement were made with the 'WHERE CURRENT OF' included in this clause.

    Now, I've changed my Ref cursor cursor, but when I compile the cursor is dynamic based is not identified, because I get the error message.

    Can someone tell me how to implement?

    I need only go to dynamic bulding of the whole procedure.

    Kind regards
    Vijayasekaran.N

    Maybe you can use around the ROWID. Like this

    Say what your actual code.

    declare
         cursor c
         is
         select *
           from t
            for update of name;
    
         lno t.no%type;
         lname t.name%type;
    begin
         open c;
         loop
              fetch c into lno, lname;
              exit when c%notfound;
    
              update t set name = lno||lname
               where current of c;
         end loop;
         close c;
    end;
    /
    

    With refcursor you can do.

    declare
         type rc is ref cursor;
         c rc;
         lno t.no%type;
         lname t.name%type;
         lrowid rowid;
    begin
         open c for 'select rowid rid, t.*
                   from t
                    for update of name';
         loop
              fetch c into lrowid,lno, lname;
              exit when c%notfound;
    
              update t set name = lno||lname
               where rowid = lrowid;
         end loop;
         close c;
    end;
    /
    

    Published by: Karthick_Arp on December 26, 2008 02:00

  • Casting table PL/SQL for the type of existing table and back ref cursor

    Hello



    I have the problem of casting a pl/sql table for the type of an existing table and turning the ref cursor to the application. Casting a ref cursor back and number of pl/sql table works well.



    Declarant

    < strong > TYPE type_table_name IS TABLE OF THE package_name.table_name%ROWTYPE; < facilities >

    within the stored procedure, fill in a table of this type temp_table_name and returning the ref cursor help

    < strong > results OPEN to SELECT * FROM TABLE (CAST (temp_table_name AS type_table_name)); < facilities >

    generates an error. type_table_name is unknown in this distribution. According to me, this happens because of the declaration of the type locally.



    Statement type_table_name inside the package specification does not work neither. Incredible, cast to the said dbms_sql.number_table to specify ref cursor back and dbms_sql package works very well!



    < strong > CREATE TYPE type_table_name IS TABLE OF THE package_name.table_name%ROWTYPE; < facilities > deals without any error but creates an invalid type complain a reference to package_name.table_name



    I don't want to declare every column in the table in type_table_name, because any change the table_name table would result in an inconsistent type_table_name.



    Thanks in advance!

    Edited by: user6014545 the 20.10.2008 01:04

    In any case you are right that there is a problem around anchorage (or maintaining) types of objects persistent to match the table structures, they may represent.

    In the case you describe, you might be better off just open the refcursor immediately the using one of the techniques described in the http://www.williamrobertson.net/documents/comma-separated.html to manage the delimited list.

    In the more general case where the line of treatment is necessary, you may make the pipeline functions.

    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    
    SQL> CREATE TABLE table_name
      2  AS
      3     SELECT ename column_name
      4     FROM   emps;
    
    Table created.
    
    SQL> CREATE OR REPLACE PACKAGE package_name
      2  AS
      3     TYPE type_name IS TABLE OF table_name%ROWTYPE;
      4
      5     FUNCTION function_name_pipelined (
      6        parameter_name IN VARCHAR2)
      7        RETURN type_name PIPELINED;
      8
      9     FUNCTION function_name_refcursor (
     10        parameter_name IN VARCHAR2)
     11        RETURN sys_refcursor;
     12  END package_name;
     13  /
    
    Package created.
    
    SQL> CREATE OR REPLACE PACKAGE BODY package_name
      2  AS
      3     FUNCTION function_name_pipelined (
      4        parameter_name IN VARCHAR2)
      5        RETURN type_name PIPELINED
      6     IS
      7     BEGIN
      8        FOR record_name IN (
      9           SELECT table_alias.*
     10           FROM   table_name table_alias
     11           WHERE  table_alias.column_name LIKE parameter_name) LOOP
     12
     13           PIPE ROW (record_name);
     14        END LOOP;
     15
     16        RETURN;
     17     END function_name_pipelined;
     18
     19     FUNCTION function_name_refcursor (
     20        parameter_name IN VARCHAR2)
     21        RETURN sys_refcursor
     22     IS
     23        variable_name sys_refcursor;
     24     BEGIN
     25        OPEN variable_name FOR
     26           SELECT table_alias.*
     27           FROM   TABLE (package_name.function_name_pipelined (
     28                     parameter_name)) table_alias;
     29
     30        RETURN variable_name;
     31     END function_name_refcursor;
     32  END package_name;
     33  /
    
    Package body created.
    
    SQL> VARIABLE variable_name REFCURSOR;
    SQL> SET AUTOPRINT ON;
    SQL> BEGIN
      2     :variable_name := package_name.function_name_refcursor ('%A%');
      3  END;
      4  /
    
    PL/SQL procedure successfully completed.
    
    COLUMN_NAME
    -----------
    ALLEN
    WARD
    MARTIN
    BLAKE
    CLARK
    ADAMS
    JAMES
    
    7 rows selected.
    
    SQL> ALTER TABLE table_name ADD (new_column_name VARCHAR2 (1) DEFAULT 'X');
    
    Table altered.
    
    SQL> BEGIN
      2     :variable_name := package_name.function_name_refcursor ('%A%');
      3  END;
      4  /
    
    PL/SQL procedure successfully completed.
    
    COLUMN_NAME NEW_COLUMN_NAME
    ----------- ---------------
    ALLEN       X
    WARD        X
    MARTIN      X
    BLAKE       X
    CLARK       X
    ADAMS       X
    JAMES       X
    
    7 rows selected.
    
    SQL>
    
  • using plsql table and ref cursor in oracle's 10 g

    Hi all
    Can someone give me an example of a scenario where we need to create a form manually based on a stored database procedure.
    And in this process, I created a pl/sql table and a Ref cursor at the database level.

    CREATE OR REPLACE PACKAGE SCOTT. TYPE BONUS_PKG IS bonus_rec
    IS (RECORD
    EmpNo bonus_EMP.empno%TYPE,
    Ename bonus_EMP.ename%TYPE,
    employment bonus_EMP.job%TYPE,
    SAL bonus_EMP.sal%TYPE,
    Comm bonus_EMP.comm%TYPE);

    TYPE b_cursor IS REF CURSOR RETURN bonus_rec;
    TYPE bontab IS TABLE OF bonus_rec INDEX DIRECTORY.

    PROCEDURE bonus_refcur (bonus_data IN OUT b_cursor);
    PROCEDURE bonus_query (bonus_data IN OUT bontab);
    END bonus_pkg;


    CREATE OR REPLACE PACKAGE BODY SCOTT. BONUS_PKG IS
    PROCEDURE bonus_query (bonus_data IN OUT bontab) IS
    II NUMBER;
    CURSOR bonselect IS
    SELECT empno, ename, job, sal, comm bonus_EMP ORDER BY empno;
    BEGIN
    OPEN bonselect.
    II: = 1;
    LOOP
    Look FOR bonselect IN
    .EmpNo bonus_data (ii),
    .ename bonus_data (ii),
    .job bonus_data (ii),
    .Sal bonus_data (ii),
    .comm bonus_data (ii);
    EXIT WHEN bonselect % NOTFOUND;
    II: = ii + 1;
    END LOOP;
    END bonus_query;

    PROCEDURE bonus_refcur (bonus_data IN OUT b_cursor) IS
    BEGIN
    Bonus_data OPEN to SELECT empno, ename, job, sal, comm bonus_EMP ORDER BY empno;
    END bonus_refcur;

    END bonus_pkg;

    I want to fill in the data in the forms manually is not using Forms data block Wizard and by program.

    Please answer...

    Can someone give me an example of a scenario where we need to create a form manually based on a stored database procedure.

    In general, you will use a block of proceedings based when you have a collection of data from several tables presented in a form and your username must be able to update the information displayed.

    In your sample code, looks like you are using Oracle Support document "Melting a block on a Stored Procedure - examples of Code [ID 66887.1]". If this is the case, continue to follow the document - it guides you through all the steps. There is no need to manually configure things that the data block Wizard will work for you!

    I want to fill in the data in the forms manually is not using Forms data block Wizard and by program.

    Why? Let the wizard block configuration data of your block based on a procedure for you. There is no need to manually browse the data! I did what you're trying, and it's more work needed. Leave forms to do the work for you. :)

    If you absolutely have to do things manually, I recommend that you use the PROCEDURE bonus_query (bonus_data IN OUT bontab) instead of bonus_refcur (bonus_data IN OUT b_cursor) . Then, in your code create a variable of type BONTAB, and then call the bonus_query procedure. Then, it's a simple case of a loop in the table of records returned by the bonus_query procedure. For example:

    DECLARE
       t_bonus    bonus_pkb.bontab;
    BEGIN
       bonus_pkg.bonus_query(t_bonus);
    
       FOR i in 1 .. t_bonus.count LOOP
          :YOUR_BLOCK.EMPLOYEE_NUMBER := t_bonus(i).empno;
          :YOUR_BLOCK.EMPLOYEE_NAME := t_bonus(i).ename;
          :YOUR_BLOCK.EMPLOYEE_JOB := t_bonus(i).job;
          :YOUR_BLOCK.EMPLOYEE_SALARY := t_bonus(i).sal;
          :YOUR_BLOCK.EMPLOYEE_COMMISSION := t_bonus(i).comm;
       END LOOP;
    END;
    

    This code example shows the basics, but as is the sample code - you will need to adapt to your situation.

    Also, I highly recommend that you look at the article inol listed. It is a very thorough debate on the REF CURSOR. If you have set up using a procedure based on the data source - it is more effective to spend the record table to your form that it must pass a ref cursor Using a ref cursor, you might as well just using a standard called cursor and loops on your named cursor. The effect is the same (a line returned at the same time creating lots of network traffic). Using the table of records is more efficient because the data set is returned if the network traffic is reduced.

    Hope this helps,
    Craig B-)

    If someone useful or appropriate, please mark accordingly.

  • 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 IS DIFFERENT FROM REF CURSOR?

    Hello
    Is the "cursor" and "ref cursor" both are different? What is the difference between them?

    Johan says:
    Yes, they are different, and the http://www.oracle.com/pls/db112/portal.all_books said all the differences.

    In fact, I'd say "Yes" and «»

    Ref Cursor and sliders are two pointers to a query as all queries are the sliders. They are both the same in this regard.
    However, how they are used, that is what makes them different. A single select statement is a slider that is implicitly opened, recovered and closed all in one action. A cursor defined in PL/SQL in contrast be implicitly open, recovered and closed (in the case of a loop FOR) or explicitly open, recovered and closed (in the case of an OPEN, FETCH... CLOSED... loop). A Ref Cursor is always explicitly open, closed and recovered, usually are opened within PL/SQL and then recovered and closed in another language such as .NET or Java. Very rarely a Ref Cursor would be used only in PL/SQL because there is really no need for them there. There are also sliders are defined using the package DBMS SQL which is very explicitly defined, parsed and executed (which is the same as OPEN) and then recovered and closed.

    All queries are the sliders, just how you access is different.

  • Retrieve the Ref cursor data

    Hello

    Here is the plsql code, I try to extract the data from the refcursor

    Declare
    number of l_ecg_id_in;
    number of l_error_code_out;
    l_cur_out sys_refcursor;
    Begin

    l_ecg_id_in: = 1249551;

    -Call the procedure
    pkg_dispatch.sp_getecgreport (p_ecg_id_in = > l_ecg_id_in,)
    p_cur_out = > l_cur_out, / / p_cur_out is back refcursor datat
    p_error_code_out = > l_error_code_out);


    Now my requirement is data retrieves in l_cur_out have too many columns, the columns are mentioned below.
    HUMAN RESOURCES
    PR
    DR
    BATTERY
    ETC.

    I want to just HR to be extacted in a variable or a collection of type

    We can extract a particular of ref cursor column, please suggest me



    End;

    Sudhir_Bangalore wrote:

    Now my requirement is data retrieves in l_cur_out have too many columns, the columns are mentioned below.
    HUMAN RESOURCES
    PR
    DR
    BATTERY
    ETC.

    I want to just HR to be extacted in a variable or a collection of type

    Then, you use the wrong cursor and you performance degradation because the cursor returns data that is not required.

    We can extract a particular of ref cursor column, please suggest me

    You can not.

    Workaround would be to copy the handle of the cursor ref to a handle to the cursor DBMS_SQL and then use cursor DBMS_SQL to treat the projection of SQL. But it would be an ugly hack.

    The right approach would be to correctly use the SQL cursors in PL/SQL. And no, ref Cursor in PL/SQL (created by code PL/SQL to PL/SQL code) is almost always the WRONG choice.

    There are better native cursor data types in PL/SQL in particular supported cursors created by PL/SQL and PL/SQL.

    REF CURSOR is provided mainly as the cursors created by PL/SQL for an external client. There are very few reasons to create Ref cursors to use PL/SQL code.

  • Best approach - whether to return Collections or the Ref Cursor?

    I have the table that the column is a nested table (column address) type. Now, I want to fill the same
    in a jsp page.

    As his collection type I am thinking to send variable Collection to front-end. And most of java professionals
    argue that the collections are the best approach.

    But here, in a lot of posts, I read that collections at the front end is the worst approach and it degrades performance
    and increases the load.

    But java assert that even if connection fails they can always display the data as the data set is with them
    How to get a set of results COLLECTION.

    As ref cursor is just a pointer to the real cursor lies in the comics... they're going to make one record of the other instead and once the connection is lost... they can no longer display the data. This assertion seems
    to be reasonable!

    How you condemn it? and prove ref Cursor is good way?


    Here's the example scenario that I have with me.
    create type t_adress is object(t_h_no varchar2(500),t_pin_code number);
     /
     
     create type t_address_tbl is table of t_adress;
     /
     
     create table r_dummy (emp_name varchar2(200),emp_id number,emp_address t_address_tbl)
     nested table emp_address store as emp_address_tbl;
     
     insert into r_dummy values('raghu',1,t_address_tbl(t_adress('598',500035),t_adress('600',500036)))
     
     insert into r_dummy values('raghu nadh',2,t_address_tbl(t_adress('598',500035),t_adress('600',500036)))
    Using the Collection
    Create or replace procedure p_using_col
     (
     p_emp_id          in     r_dummy.emp_name%type,
     p_emp_dtls          out     t_address_tbl
     )
     is
     begin
              Select     t_adress(cl.t_h_no,cl.t_pin_code)
              bulk collect into p_emp_dtls
              from     r_dummy,table(emp_address) cl
              where     emp_id = p_emp_id;
     
     end;
     /
     
     set serveroutput on;
     declare
              l_emp_id          r_dummy.emp_name%type := 1;
              l_emp_dtls          t_address_tbl;
     begin
              p_using_col(l_emp_id,l_emp_dtls);
              
              for i in 1..l_emp_dtls.count
              loop
              
                   dbms_output.put_line(l_emp_dtls(i).t_h_no);
              
              
              
              
              end loop;
     
     
     end;
    Using Ref Cursor
    Create or replace procedure p_using_ref
     (
     p_emp_id          in     r_dummy.emp_name%type,
     p_emp_dtls          out     sys_refcursor
     )
     is
     begin
              Open p_emp_dtls for
                   Select     cl.t_h_no,cl.t_pin_code
                   from     r_dummy,table(emp_address) cl
                   where     emp_id = p_emp_id;
     
     end;
     /
     
     set serveroutput on;
     declare
              l_emp_id          r_dummy.emp_name%type := 1;
              l_emp_dtls          sys_refcursor;
              
              l_h_no               varchar2(500);
              l_pin_code          number;
              
              
     begin
              p_using_ref(l_emp_id,l_emp_dtls);
              
                   loop
                        fetch l_emp_dtls into l_h_no,l_pin_code;
                        
                        exit when l_emp_dtls%notfound;
                        dbms_output.put_line(l_h_no||'    '||l_pin_code);
                   
                   
                   end loop;
              
                   close l_emp_dtls;
     end;
    Concerning
    RUSSO

    RUSSO says:
    I would like to know what really happens behind the screen IE in PGA... when we return collections...

    A collection is a PL/SQL variable. Like all PL/SQL variables, it resides in the global area of the server process that executes PL/SQL code. This memory is part of the process the process's private memory.

    If need more memory, more memory server be malloc' ed by the process.

    As he is dedicated and private memory, no other process can reap the benefits of this memory in use. It is not 'ideal' - shared memory however benefits all the processes that are involved in sharing that allocated the memory. As is the case with the SGA

    How long my set of data will reside in the PGA? He immediately fade after returning to the calling procedure? and how it degrades performance. Help me with a good link.

    Assume that you create a collection of 10 MB. The process server malloc' ed 10 MB of server memory. The PGA has thus extended.

    When your code executes the variable usage (it is out of reach of runtime), the PL/SQL engine can theoretically free up 10 MB of memory. However, it may have allocated 4 KB memory after this assignment of 10 MB. Only 4 KB is still in use. This moment results in that the process cannot shrink its allocated memory - as this free piece of 10 MB is slapbang in the middle of the used memory space.

    PGA memory is 'expensive' because it's not shared memory is private, with only the current process. PGA in memory is not so easy to decline. Memory management is a complex issue and you who ceases to use a large part of the PGA memory almost never means that this memory suddenly become free and available for other processes to use.

    Also, you have to ask yourself why you want to copy data from disk blocks into the SGA buffer (for SQL procedures) cache, then copy these data blocks of APG in the PGA (using a collection and extraction in bulk) and then copy this PGA memory on the network to the client process (TOAD or .net or Java or whatever).

    It's a lot of moving parts - which increases the complexity, lowers the performance and scalability and ups the risk of something going wrong due to the increased complexity.

    It is much simpler and much stronger, to maintain the number of moving parts to a minimum. For example to copy data directly from cache buffers of the SGA to the customer via a ref cursor

  • REF cursor kicking package compilation error

    I have a package with the following procedure:
    PROCEDURE INTERPRET_DATAVRSN (
         p_table      IN VARCHAR2)
    
    AS
       cursor Generic_Tab IS REF CURSOR;
    
       c_sub Generic_Tab;
       v_SQL VARCHAR2(2000);
       v_SQLUpdate VARCHAR2(2000);
       v_RawDataVrsn VARCHAR2(200);
    
    BEGIN
       -- Start by selecting all of the unique values in the table.
       v_SQL := 'select distinct DataVrsn_in from '||p_table||' ';
    
       OPEN c_sub for v_SQL;
       -- Then process each unique value.
       Loop
          FETCH c_sub into v_RawDataVrsn;
          exit when c_sub %notfound;
    
            v_SQL := 'update '||p_table||' set DataVrsn=''';
          if (Instr(Upper(trim(v_RawDataVrsn)), 'V') > 0) then
             begin
                v_SQL := v_SQL||Replace(v_RawDataVrsn, 'V', '')||''' ';
             end
          else
             begin
                 v_SQL := v_SQL||v_RawDataVrsn||''' ';
             end
          end if;
    
        v_SQL := v_SQL||''' where DataVrsn_in='''||v_RawDataVrsn||''' ';
    
            EXECUTE IMMEDIATE v_SQL;
       end loop;
       close c_sub;
       commit work;
    
         EXCEPTION
              WHEN OTHERS THEN
               /*DBMS_OUTPUT.PUT_LINE(' Received CODE=' || SQLCODE || '  MESSAGE=' || SQLERRM);*/
             RAISE;
    
    END INTERPRET_DATAVRSN;
    It keeps giving me the error "encountered the symbol"REF"during awaits one of the following values:" any idea of another way to do this dynamic SQL cursor, or is there something I'm not here?

    Thank you!

    Hello

    It should be

    type Generic_Tab IS REF CURSOR;
     
    

    and is not

    cursor Generic_Tab IS REF CURSOR;
    

    In addition, your if condition does not have a begin and end, you can change it to

          if (Instr(Upper(trim(v_RawDataVrsn)), 'V') > 0) then
    
                v_SQL := v_SQL||Replace(v_RawDataVrsn, 'V', '')||''' ';
    
          else
    
                 v_SQL := v_SQL||v_RawDataVrsn||''' ';
    
          end if;
    

    Arun-

  • 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

  • Ref Cursor and type

    Hi all

    I finally got the job of procedure stored Ref Cursor but am stuck on the following. I have this package body:

    CREATE OR REPLACE PACKAGE BODY PACK_MYCURSOR AS
    PROCEDURE REFCUR)
    theuserid IN OUT users.user_id%type,
    UserFirstName to users_TableRows) IS
    BEGIN
    OPEN FOR UserFirstName
    Select * from users
    Where user_id = theuserid
    ;
    END REFCUR;
    END PACK_MYCURSOR;
    /

    Now it works fine, but I need to have fields of explisit in the select statement, such as "select user_id from users", but when I do that then I would get the error messages of "expression is of the wrong type." Someone knows how to fix this?

    Thank you.

    Declare your as WEAK rather than STRONG type ref cursor. In other words, do not specify return rowtype % ROWTYPE in your statement in the specification.

    Declare that:
    TYPE users_TableRows IS REF CURSOR;

    Phil

Maybe you are looking for

  • calendar for the week of jQuery does not work in the new version of firefox v42.0

    HelloThanks for your reply.IAM develop on the issue that iam facing knowledge, events on the calendar for the week of jquery does not work in firefox version iam 42.0 faced to the problem that iam unable to change back or delete nominations that are

  • My 5s not iPhone connect to iTunes

    I have apps on my iMac iTunes sync page which do not go to my phone is when sync.  Tries to go to the Apple app store by searching app store when list arrives I click the app store link, and then open a message ' do you want to open it in iTunes "cli

  • AT10LE 4.3 updated Android available

    4.3 Android update is available. The download is slow, but the new system feels good. It seems a bit smoother, and of course Android 4.3 has some novelty. Thank you, Toshiba, and I hope that we will see 4.4 soon.

  • DC7700 Compatible processors

    Hey everybody.  I am new to the forum and do not know if this is where I can post my questions CPU. I recently found in possession of a DC7700 with Pentium D 945 @3. 40 GHz.  I know this is an old PC, but it works very well with Win8.  I was looking

  • How can I synchronize my Windows Live Mail 2011 on my desk top of the page to insert through to my phone I 4 s?

    Original title: * e-mail address is removed from the privacy *. How can I synchronize my Windows Live Mail 2011 on my desk top of the page to insert through to my phone I 4 s. I get the message on mobile phone "Cannot get Mail" * address email is rem