via return Produre Ref Cursor

Hi all

I am trying to create the stored procedure that will return the recordset below is the code:

create or replace procedure manager_holdings (l_table_name varchar,

number of l_client_id

l_process_type varchar2,

l_process_date varchar2,

l_enc_tenant_id varchar2,

p_recordset OUT SYS_REFCURSOR) as

sql_stmt varchar2 (4000);

Start

sql_stmt: ='

Select * from)

with t1 as

(select smo.security_id, rsm.security_desc, sum (smo.closing) sum_each_sec

of ' | l_table_name | "smo, rsm rage_security_master.

where smo.client_id = ' | l_client_id |

"and smo.process_type = ' |" l_process_type |

"and smo.process_date = ' |" l_process_date |

"and smo.enc_tenant_id = ' |" l_enc_tenant_id |

"and smo.security_id = rsm.security_id

Smo.security_id group, rsm.security_desc having count (smo.security_id) > 1)

Select security_id, security_desc from t1 by security_id

) security_id order ';

run immediately sql_stmt into p_recordset;

end manager_holdings;

but when I test it I get error below:

Types of data inconsistent-ORA-00932: expected -. -

ORA-06512:

could you please help me

Thank you

Its resolved, I tried the below code: and his works fine. Thanks too all for help

create or replace procedure sp_manager_holdings (l_table_name varchar2,

number of l_client_id

l_process_type varchar2,

l_process_date Date,

l_enc_tenant_id varchar2,

p_recordset OUT SYS_REFCURSOR) as

Start

run immediately "start

Open: p_recordset for

Select security_desc, composite, manager_name, mang_composite

Of

(

with t1 as

(select smo.security_id, rsm.security_desc, sum (smo.closing) sum_each_sec of ' |)

l_table_name |

"smo, rsm rage_security_master.

where smo.client_id =: l_client_id

and smo.process_type =: l_process_type

and smo.process_date =: l_process_date

and smo.security_id = rsm.security_id

and smo.enc_tenant_id =: l_enc_tenant_id

Smo.security_id group, rsm.security_desc having count (smo.security_id) > 1)

,

As T2

(select sum (smo.closing) sum_all_sec of ' |)

l_table_name |

"smo".

where smo.client_id =: l_client_id

and smo.process_type =: l_process_type

and smo.process_date =: l_process_date

and smo.enc_tenant_id =: l_enc_tenant_id

and smo.asset_id = 1),

T3 as

(select distinct (sm.manager_id), md.manager_name, sum (sm.closing) sum_each_mang of ' |)

l_table_name | "sm, md manager_details where.

SM.asset_id = 1

and sm.client_id =: l_client_id

and sm.process_type =: l_process_type

and sm.process_date =: l_process_date

and sm.enc_tenant_id =: l_enc_tenant_id

and sm.manager_id = md.manager_id

Sm.manager_id, md.manager_name).

T4 in

(

selecT distinct sm.security_id, sm.manager_id, sum (sm.closing) sum_all_mang

of ' | l_table_name | "sm, md manager_details.

where security_id in

(select smo.security_id

of ' | l_table_name | "smo, rsm rage_security_master.

where smo.client_id =: l_client_id

and smo.process_type =: l_process_type

and smo.process_date =: l_process_date

and smo.enc_tenant_id =: l_enc_tenant_id

and smo.security_id = rsm.security_id

Smo.security_id group, rsm.security_desc

having count (smo.security_id) > 1)

and sm.manager_id in

(select distinct (smo.manager_id)

of ' | l_table_name | "smo".

where smo.asset_id = 1

and smo.client_id =: l_client_id

and smo.process_type =: l_process_type

and smo.process_date =: l_process_date

and smo.enc_tenant_id =: l_enc_tenant_id

Smo.manager_id group

)

and sm.client_id =: l_client_id

and sm.process_date =: l_process_date

and sm.process_type =: l_process_type

and sm.enc_tenant_id =: l_enc_tenant_id

and sm.asset_id = 1

and sm.manager_id = md.manager_id

Sm.security_id group, sm.manager_id

)

Select DISTINCT t1.security_id,

T1.security_desc,

Round (((t1.sum_each_sec / t2.sum_all_sec) * 100)) composite.

T3.manager_id,

T3.manager_name,

Round (((t4.sum_all_mang / t3.sum_each_mang) * 100)) mang_composite

T1, t2, t3, t4

where t1.security_id = t4.security_id (+)

and t3.manager_id = t4.manager_id (+)

order of t1.security_id

)

; end; »

using p_recordset, l_client_id, l_process_type, l_process_date, l_enc_tenant_id;

end sp_manager_holdings;

Tags: Database

Similar Questions

  • 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

  • Calling an Oracle stored procedure that returns a REF cursor

    Hi guys,.

    I'm calling an Oracle stored procedure that returns a REF CURSOR. Here is the piece of code that I'm working on:

    procedure TC307_MAIN (p_program varchar2, varchar2, varchar2, result_set OUT eng_cur p_engchgno p_project) as
    Start
    IF (p_program = 'Navybased' and p_project = 'PROTECTOR-BUILD') THEN
    result_set: = comments. Tc307_Eng_Chg_Rpt.TC307_RNZN (p_engchgno, result_set = >);
    END IF;
    end TC307_MAIN;

    procedure TC307_RNZN (p_engchgno varchar2, result_set IN OUT eng_cur) as
    Start
    end TC307_RNZN;

    PL/SQL code behind TC307_RNZN is big enough, that's why I've not stuck here. Basically, the second stored procedure executes a PLSQL statement and returns a result set. I need to return the result_set in the main proceedings based on nested else statement which I am still trying to build. I get a compilation... error can someone guide me with the correct method to call the second stored procedure and returning in the main proceedings.

    Thank you very much.

    Rohan,

    Try this

    procedure TC307_MAIN(p_program  varchar2,
                           p_project  varchar2,
                           p_engchgno varchar2,
                           result_set OUT eng_cur) as
      begin
           IF (p_program = 'RNZN' and p_project = 'PROTECTOR-BUILD') THEN
                  -- This is a procedure not a function
                         guest.Tc307_Eng_Chg_Rpt.TC307_RNZN(p_engchgno, result_set); --UR compilation error on this line*
          END IF;
      end TC307_MAIN;
    

    SS
    http://DB-Oracl.blogspot.com

  • REF CURSOR in DB

    Hello

    I have a procedure in the scheme, saying, 'a' DB 'A' that returns a REF CURSOR. I run the procedure of a 'b' in 'B' DB schema However, it gives me an error "end of file...". '. Is it because only Oracle does not support REF CURSOR to be sent to the DB? If so, are there alternatives to achieve the result expected in b@B?

    Thanks in advance

    Is it because only Oracle does not support REF CURSOR to be sent to the DB?

    Yes:

    »
    A cursor variable is allowed in a RPC Server-server only if the remote database is not a database of accessible Oracle via a procedural bridge.
    «

  • Ref cursor error message

    Hello expert;

    I have a function that returns a ref cursor, but the function may not return anything. I would like to know what is the best way to manage the error message

    ORA-06503: PL/SQL: function returned no value - slider Ref

    .. Please see below.

    function f_de return latest_cur is
    my_l_cur l_cur;
    
    begin
    open my_l_cur for
    select max(dateadded) as dateadded
    from tbl_test;
    end;
    

    I was wondering what is the best way to manage. I know I could use a count, and if the number is greater than 0, manipulate, but I was looking for the best way to manage it.

    user13328581 wrote:

    Hello expert;

    I have a function that returns a ref cursor, but the function may not return anything. I would like to know what is the best way to manage the error message

    ORA-06503: PL/SQL: function returned no value - slider Ref

    .. Please see below.

    1. latest_cur the f_de function return is
    2. my_l_cur l_cur;
    3. Start
    4. Open the my_l_cur for
    5. Select max (dateadded) as dateadded
    6. of tbl_test;
    7. end;

    I was wondering what is the best way to manage. I know I could use a count, and if the number is greater than 0, manipulate, but I was looking for the best way to manage it.

    by definition a FUNCTION returns a value, but your code isn't working; Therefore, the error is thrown.

    RETURN MY_L_CUR;

    the top line should take place before the END; statement.

  • Ref Cursor

    Hi guys,.

    You can develop the ref cursor please. I'm new to the plsql...

    Hi Alex,

    Introduction to the REF CURSOR

    With the help of REF CURSOR s is one of the most powerful, flexible and scalable means to return the query results to an Oracle database to a client application.

    A REF CURSOR is a PL/SQL data type whose value is the memory address of a workspace of query on the database. In essence, a REF CURSOR is a pointer or a handle to a game on the database of results. REF CURSOR s are represented by the OracleRefCursor class ODP.NET.

    REFCURSORs have the following characteristics:

    • A REF CURSOR refers to a memory on the database address. Therefore, the client must be connected to the database during the lifetime of the REF CURSOR to access.
    • A REF CURSOR involves a round-trip of additional database. While the REF CURSOR is returned to the customer, the actual data is not returned until the customer open it REF CURSOR and requests the data. Note that the data are not be retrieved until the user tries to read it.
    • A REF CURSOR is not editable. The result set represented by the REF CURSOR is read-only. You cannot update the database using a REF CURSOR .
    • A REF CURSOR is not back with scroll. The data represented by the REF CURSOR is only accessible in a way before and in series. You cannot position a record pointer inside the REF CURSOR to point to records in the result set.
    • A REF CURSOR is a PL/SQL data type. You create and return a REF CURSOR within a block of PL/SQL code.

    See this link which explained on cursor by Zerathul ref: PL/SQL 101: understanding Ref Cursor

    Kind regards

    Jitendra

  • Report regions - use of the Ref Cursor?

    APEX 4.2

    See http://mikesmithers.wordpress.com/2012/02/22/getting-apex-to-play-with-ref-cursors

    The above article is older than 2 years. The techniques shown in the link above still valid today if we want to create a report region in the APEX are based on a function that returns a Ref Cursor? Are there improvements in this area for the next APEX 5.0 and/or database Oracle 12 c?

    Thank you

    HELEN wrote:

    APEX 4.2

    See http://mikesmithers.wordpress.com/2012/02/22/getting-apex-to-play-with-ref-cursors

    The above article is older than 2 years. The techniques shown in the link above still valid today if we want to create a report region in the APEX are based on a function that returns a Ref Cursor?

    If the function returns the ref cursor is the only point of access that you have data then Yes, it probably is. If you have direct access to the underlying database objects and the function does not have something very complicated, then you are probably better off creating your own body of the function returning SQL query data source.

    Everything about the dynamics of ref Cursor now I divided in 2 layers, with a function for generating the dynamic SQL and another for bind parameters open the ref cursor. APEX apps can then reuse the functions of SQL query in function body return SQL query data sources (if you take a bit of care to keep the bind variable names vaguely APEX-point-friendly).

    Are there improvements in this area for the next APEX 5.0 and/or database Oracle 12 c?

    See this for the technical background on why APEX is not yet support ref Cursor and this for more information of the Oracle team on the possibility of future support. Obviously, he did not he in 4.1. I suspect that data REF CURSOR region sources depended on a minimum requirement of DB of the 11.1.0.6 (where was introduced support for the conversion of the REF CURSOR in the cursors DBMS_SQL). As minimum DB for APEX 5.0 version is 11.1.0.7, it would be a possible feature for 5.0, but it is not classified as one.

  • How to start the view off of the ref cursor Oracle as input/output param

    Hello world

    We use JDev 11.1.2.3 WL 10.3.6 and Java 7.

    We are at the beginning of our transition from Oracle Forms to ADF.  We have a very large forms that uses many store procedures that have IN/OUT ref Cursor parameters and tables plsql.  I tried to find information on best practices to achieve, but only seemed to find tutorials on SEO of the Oracle ref Cursor return functions.  I hope we don't have to rewrite our code of database to work with ADF.

    This is an example of a proc currently a block on a form based on directly

    The ref cursor parameter is input/output to satisfy the way the form handles this type of paradigm.

    ADF we want I hope to reuse these procs existing (without the need to wrap/overload them) on the basis of the display objects.

    Example:

    / * my record type which houses the information I want to go back * /.

    TYPE rec_hist_vacpac_status IS RECORD)

    rec_order NUMBER (5),

    rec_rownum NUMBER (5),

    return_column SAM_VACPAC.vacpac_status%TYPE,

    rec_login_id SAM_VACPAC.ins_user%TYPE,

    status_date SAM_VACPAC.status_date%TYPE

    );

    / * Sets the ref cursor type * /.

    TYPE lcur_hist_vacpac_status IS REF CURSOR;

    / * This is a procedure that would take some info link go / return

    Return the ref cursor of this information as an in / out * /.

    PROCEDURE prc_myinfo_refcur)

    pnum_identify_seq_id in NUMBERS

    pcur_myinfo IN OUT lcur_hist_vacpac_status);

    Can anyone point me in the right direction on documentation on this?

    Thank you!

    Hi Cemerson:

    See this example:

    1. 1. create a TYPE as an object

    CREATE OR REPLACE

    TYPE GOTYOB_EQUI

    AS AN OBJECT

    (

    CDELEM VARCHAR2 (50).

    TIELEM VARCHAR2 (2)

    );

    1. 2. create a TABLE TYPE AS

    CREATE OR REPLACE

    TYPE GOTYTA_EQUI

    AS THE GOTYOB_EQUI TABLE;

    1. 3 create a function, it returns the TYPE of the TABLE

    FUNCTION fn_equiposarriba)

    pa_cdelem IN VARCHAR2,

    pa_nucomp in NUMBERS

    pa_anperi in NUMBERS

    pa_meperi in NUMBERS

    )

    Gotyta_equi RETURN PIPELINED IS

    CURSOR trae_equimani (va_cdelem VARCHAR2) IS

    SELECT cdelem, tielem, cdelempadr,

    (SELECT cdequi

    Of evm_alim

    WHERE anperi = eq.anperi

    AND meperi = eq.meperi

    AND nucomp = eq.nucomp

    AND cdalim = eq.cdalim) cdalim

    Of evm_equimani eq

    WHERE anperi = pa_anperi

    AND meperi = pa_meperi

    AND nucomp = pa_nucomp

    AND cdelem = va_cdelem

    AND cdelempadr <> cdelem

    AND tielem <> 'A ';

    equimani trae_equimani % ROWTYPE;

    va_cdalim VARCHAR2 (100);

    BEGIN

    -Loading los equipos aguas arriba

    WHILE equimani.cdelempadr IS NOT NULL LOOP

    OPEN trae_equimani (equimani.cdelempadr);

    equimani: = NULL;

    SEEK trae_equimani INTO equimani;

    CLOSE Trae_equimani;

    IF equimani.cdelem IS NOT NULL THEN

    PIPE ROW (gotyob_equi (equimani.cdelem, equimani.tielem));

    END IF;

    END LOOP;

    RETURN;

    END;

    1. 4 SQL Query with the help of the function... you can use this SQL in a display object

    SELECT

    *

    Of

    TABLE (gopq_eventos.fn_equiposarriba (' F-SCZ-043-103', '))

    1,

    2013,

    6

    )

    )

    Best regards, Marcelo

  • Initialize the Ref Cursor to avoid ORA-01001: Invalid cursor

    Hello

    I write a stored procedure that returns a REF CURSOR. However, there are times when the cursor is not open if certain conditions are not met, so I wonder if there is a way to initialize the REF CURSOR so that the appellant does not receive the "ORA-01001: Invalid cursor" error when you try to work with the cursor, if it has not been opened.

    Any help is greatly appreciated...

    Thank you
    Christine

    cad0227 wrote:
    Hello

    I write a stored procedure that returns a REF CURSOR. However, there are times when the cursor is not open if certain conditions are not met, so I wonder if there is a way to initialize the REF CURSOR so that the appellant does not receive the "ORA-01001: Invalid cursor" error when you try to work with the cursor, if it has not been opened.

    Any help is greatly appreciated...

    Thank you
    Christine

    The most appropriate way would be the caller to handle the situation. The caller must capture the exception of INVALID_CURSOR and do what is necessary.

    Other suggestions like having a separate Pavilion or a model select all will lead the appellant to act to the particular situation, that slider is not being opened. What is the case with the exception of INVALID_CURSOR raised by oracle.

    All the need for the appellant to do is manage the exception of INVALID_CURSOR and you should be good. And also INVALID_CURSOR is not a mistake, it's an exception that has a special meaning for her. In the case you sense it takes the condition when not together to return a cursor.

  • How to create a Ref cursor table

    I have a proc that returns a Ref Cursor, what is the easiest way to create a table based on the return of the ref cursor?

    declare
    type rc is ref cursor;
    p_data rc;
    Start
    call_my_proc (p_data);
    : result: = p_data; ((- If I run this in TOAD I can see the data here, but I want to create a table based on it rather than showing)
    end;


    Thank you.


    Edit: sorry. typed this wrong, first time, should be right now

    I recommend you read this first... {: identifier of the thread = 886365}

    and then you'll have a better idea of how to make to create a table in your query.

  • join a Ref cursor to a table

    Hello all;

    Can you please show me a simple example on how to join a Ref cursor to a table, because I have a function that returns a Ref Cursor and I want to call this function in another function (B) and then he join a table in this function (B)

    How do I join a Ref cursor to a table

    I can do on my 11 GR 2

    SQL> declare
      c         sys_refcursor;
      l_ename   emp.ename%type;
    begin
      open c for
        select * from dept where loc = 'DALLAS';
    
      select ename
        into l_ename
        from emp, xmltable ('ROWSET/ROW' passing xmltype (c) columns deptno number path 'DEPTNO') x
       where emp.deptno = x.deptno
         and rownum = 1;
    
      dbms_output.put_line (l_ename);
    end;
    /
    SCOTT
    PL/SQL procedure successfully completed.
    
  • How to pass a REF CURSOR from a function

    I tried to compile the following function:

    CREATE or REPLACE FUNCTION example
    RETURN REFCURSOR
    IS
    heart REFCURSOR;
    BEGIN
    OPEN FOR heart
    "SELECT x FROM table";
    RETURN cur;.
    END;

    but I get:

    PLS-00201: identifier 'REFCURSOR' must be declared.

    Can you help me in the right syntax? I never return a REF CURSOR to a function.
    Is my Version of Oracle 8.1.7

    Thank you!

    You cannot use SYS_REFCURSOR in Oracle 8i.
    The work is approximately as follows

    create or replace package my_pk as
    type my_cur is REF CURSOR;
    end my_pk;
    
    -- Now write your function
    create or replace function my_func return my_pk.my_cur
    as
    l_cur my_pk.my_cur;
    begin
    open l_cur for select * from table_name;
    return l_cur;
    end my_func;
    

    Thank you
    Andy

  • Dynamic SQL with a Ref Cursor

    Hello

    I have a package that returns a Ref Cursor, in this procedure, I have a dynamic sql code that is built according to certain values, and the query is a select query, is it possible that I can put that dynamic sql in the ref cursor and return of the procedure.

    Or y at - it no alternative better workaround.

    Thanks in advance.

    Naveen

    Yes you can.

    Try this...

    create or replace package test_pack is
    type ref_cur is ref cursor;
    procedure just_print(ref_var ref_cur);
    end;
    /
    
    create or replace package body test_pack is
    procedure just_print(ref_var ref_cur) is
    l_var emp%rowtype;
    begin
    loop
    fetch ref_var into l_var;
    exit when ref_var%notfound;
    dbms_output.put_line(l_var.ename);
    end loop;
    end;
    end;
    /
    
    declare
    cur_var test_pack.ref_cur;
    dsql varchar2(100);
    begin
    dsql := 'select * from emp where deptno=10';
    open cur_var for dsql;
    test_pack.just_print(cur_var);
    end;
    /
    CLARK
    KING
    MILLER
    
    PL/SQL procedure successfully completed.
    
    Elapsed: 00:00:00.00
    

    Kind regards
    Prazy

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

Maybe you are looking for

  • Cannot compress files

    I am running OS X Yosemite on my Mac Book Air.  I have a few that I would like to compress large files, but it is not an option for any of my files.  On the file menu, the compression option is grayed out.  I'm mainly looking to PowerPoint files, but

  • Touchpad on my Satellite C50-A-157 problem

    Hi, I had some problems with the touchpad my * Toshiba Satellite C50-A-157 * portable. I use windows 8, and I've had my laptop for a few weeks, but suddenly, all the vofI can only use the touchpad and operate the cursor when I have one of the buttons

  • U2312HM

    I know that DELL is no longer manufacture the U2312HM monitor, but Dell has no stock? No matter its new or reconditioned, I really want one more to compensate for the double posting please. Or y at - it another way that I can get one? Please check it

  • Contact folder settings change Z10 blackBerry does not stick

    I have a z10 connected to exchange 2013 via activesync.  Randomly, my selections "edit contacts folder settings" gets delivered to all contacts folders.  I also noticed when this happens that my contacts are all gone, and I have to disable/re-enable

  • RVS4000 Firewall ACL Question

    I work to install and configure a RVS4000 for a friend and wanted to check my understanding of the firewall section.  He by default the firewall allows traffic from any source to any destination, including Wan.  I realize with NAT, this isn't a huge