Number of Bind variables passed  AND   Ref Cursor

hi all
well i have an interesting problem
i need to construct a query for a refcursor besade on conditions....
as:
input params: in_lname and in_fname
sql_stmt := 'Select first_name, ' || 'last_name, ' ||
'from table1';
IF in_lname is not null then
-- we are selecting guests by Lastname, Lastname & Firstname,
-- Lastname & Firstname & Zip, or Lastname & Zip
sql_stmt := sql_stmt || 'where gc_last_name = :1 ';
IF in_fname is not null then
sql_stmt := sql_stmt || ' and gc_first_name = :2 ';
END IF;
END IF;
open fm_lom_cv for sql_stmt using in_lname, in_fname;
Now here the in_lname is required BUT in_fname can be NULL
hence we dont excute or create the sql with sql_stmt || ' and gc_first_name = :2 ';
so :2 will not be used
hence it gives error IF in_fname is null ie ORA-01006: bind variable does not exist
Please suggest how to handle it....
thanks

may you have to set a some variable to check
not perfect but somthing like this
declare
ct number:=1;
sql_stmt varchar2(150);
BEGIN
  sql_stmt := 'Select first_name, ' || 'last_name, ' ||
              'from table1';
IF in_lname is not null then
-- we are selecting guests by Lastname, Lastname & Firstname,
-- Lastname & Firstname & Zip, or Lastname & Zip
   sql_stmt := sql_stmt || 'where gc_last_name = :1 ';
   ct:=1;
   IF in_fname is not null then
      sql_stmt := sql_stmt || ' and gc_first_name = :2 ';
    ct:=2; 
    END IF;
END IF;
  case when ct=1 then
Open fm_lom_cv for sql_stmt using in_lname;
when ct=2 then
Open fm_lom_cv for sql_stmt using in_lname,in_fname;
end case;  
  

Similar Messages

  • NESTED TABLE BIND VARIABLE IN A REF CURSOR

    Hi,
    this works:
    open c_ref for v_sql using cp_asset_type
    where cp_asset_type is a nested tables passed into the proc as an 'in' parameter, but since the number of passed tables varies I loaded the nemes into an a nested table and tried the following:
    -- ELSIF BIND_COUNT.COUNT = 8 THEN
    -- OPEN C_REF FOR V_SQL
    -- USING BIND_COUNT(1),BIND_COUNT(2),BIND_COUNT(3),BIND_COUNT(4),BIND_COUNT(5),BIND_COUNT(6),BIND_COUNT(7),BIND_COUNT(8);     
    -- END IF;     
    which produced :
    ORA-22905 CANNOT ACCESS ROWS FROM A NON-NESTED TABLE ITEM
    my guess is that I'm passing the varchar2 names of the nested tables and the 'using' statement needs the actual table ????
    if this is true is there any way to pass a pointer for the bind variable nested tables?
    Thanks,
    Victor

    <br>i removed the AND...but m still getting the same error.
    <br>Is this a versioning problem...since urs is 9i and m using
    <br>Oracle8i Enterprise Edition Release 8.1.7.4.0
    <br> PROCEDURE sp_SearchByDriverName(i_C in varchar2,
    i_F in varchar2,
    i_LN in varchar2,
    i_FN in varchar2,
    o_Result out ABC_CURTYPE) is
    <br> tm_corp varchar2(2);
    <br> tm_fleet varchar2(6);
    <br> dc ABC_curtype;
    <br> begin
    <br> tm_c := getformattedc(i_C);
    <br> tm_f := getformattedf(i_f);
    <br> if i_FN is not null then
    <br> open dc for
    <br> SELECT distinct b.bus_ref_access_value,
    <br> i.individual_id,
    <br> br.mf_driver_last_name LN,
    <br> br.mf_driver_first_name FN,
    <br> substr(b.bus_ref_access_value, 4, 6) FLEET1,
    <br> (select '4444' from dual) --error is still coming here
    <br> FROM bus_ref_access_values b,
    <br> bus_ref_list brl,
    <br> individual i,
    <br> unit_contact_list f,
    <br> unit u,
    <br> bus_ref_current_prop br
    <br> WHERE b.bus_ref_id = br.bus_ref_id AND
    <br> b.bus_ref_id = brl.bus_ref_id AND
    <br> brl.reference_id = u.reference_id AND
    <br> u.unit_id = f.unit_id(+) AND
    <br> i.individual_id = f.individual_id AND
    <br> f.contact_type_ref = 'DR' AND
    <br> br.mf_driver_last_name like i_LN || '%' AND
    <br> br.mf_driver_first_name like i_FN || '%' AND
    <br> substr(b.bus_ref_access_value, 1, 2) = tm_c AND
    <br> substr(b.bus_ref_access_value, 4, 6) = tm_f AND
    <br> b.bus_ref_access_label = 'UNIT NUMBER'
    <br> ORDER BY 4, 3, 2;
    <br> close dc;
    <br>end if;

  • Using plsql table and ref cursor in oracle forms 10g

    Hi all,
    Can anyone give me an example of a scenario where we need to create a form manually based on a database stored procedures.
    And in that procedure i have created a pl/sql table and a ref cursor in data base level.
    CREATE OR REPLACE PACKAGE SCOTT.BONUS_PKG IS TYPE bonus_rec
    IS RECORD(
    empno     bonus_EMP.empno%TYPE,
    ename     bonus_EMP.ename%TYPE,
    job     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 BY BINARY_INTEGER;
    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 FROM bonus_EMP ORDER BY empno;
    BEGIN
    OPEN bonselect;
    ii := 1;
    LOOP
    FETCH bonselect INTO
    bonus_data( ii ).empno,
    bonus_data( ii ).ename,
    bonus_data( ii ).job,
    bonus_data( ii ).sal,
    bonus_data( ii ).comm;
    EXIT WHEN bonselect%NOTFOUND;
    ii := ii + 1;
    END LOOP;
    END bonus_query;
    PROCEDURE bonus_refcur(bonus_data IN OUT b_cursor) IS
    BEGIN
    OPEN bonus_data FOR SELECT empno, ename, job, sal, comm FROM bonus_EMP ORDER BY empno;
    END bonus_refcur;
    END bonus_pkg;
    i want to populate the data in forms manually not using forms data block wizard and programmatically.
    please reply...

    Can anyone give me an example of a scenario where we need to create a form manually based on a database stored procedures.Typically, you would use a procedure based block when you have a collection of data from multiple tables presented in a Form and your user needs to be able to update the information displayed.
    From your code example, it looks like you are using Oracle Support document "Basing a Block on a Stored Procedure - Sample Code [ID 66887.1]". If this is the case, keep following the document - it walks you through all of the steps. There is no need to Manually configure things that the Data Block Wizard will perform for you!
    i want to populate the data in forms manually not using forms data block wizard and programmatically. Why? Let the Data Block Wizard take care of configuring your block based on a procedure for you. There is no need to manually loop through the data! I've actually done what you are attempting and it was more work than was needed. Let Forms do the work for you. :)
    If you absolutely must do things manually, I recommend you use the PROCEDURE bonus_query(bonus_data IN OUT bontab) instead of the 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 is a simple case of looping through 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 sample demonstrates the basics, but as it is sample code - you will have to adapt it to your situation.
    Also, I strongly recommend you look at the article InoL listed. This is a very comprehensive discussion on REF CURSORs. If you are set on using a procedure based data source - it is more efficient to pass the table of records back to your form than it is to pass a ref cursor. Using a ref cursor, you might as well just using a standard named cursor and loop through your named cursor. The effect is the same (one row returned at a time creating lots of network traffic). Using the table of records is more efficient because the entire data set is returned so network traffic is reduced.
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Link Query and Ref Cursor Query

    Hi all!!
    How can I link Query and Ref Cursor Query??
    I mean, How can I pass input parameters to the PL/SQL procedure if they are not User parameters but they come from another table??
    Thanks a lot
    F.

    I have searched the forum and this is the closest to my problem.
    Just started using ref cursors in my reports.
    The problem I am running into is that I have two ref cursor queries in my report - they each contain a column named seq_no which forms a join (in the database) .
    My report returns the correct number of records in each query, but I can't find a way to enforce the join. I've tried all the methods I can think of including combining the results into one query.
    The IDE won't let me join on a column and when I join on the group (which I make only contain the seq_no fields) that join is ignored.
    Can anyone help me on this?

  • Unknow number of binding variables in Dynamic SQL

    I have to use a dynamic sql and binding variables. The problem is the number of binding variable varies due to the form input.
    EX.
    if ( something is not null ) then
    query := query || ' and column = :column';
    end if;
    if ( something_else is not null ) then
    query := query || ' and another_column = :another_column';
    end if;
    When I use in my USING clause, I don't know which of the four combinations of column/another_column I could be
    open query;
    open query using A,B;
    open query using A;
    open query using B;
    How can I solve this problem?
    Thanks a lot!

    Always with NVL:
    query := query || ' AND column = NVL(:column,column ) AND another_column = NVL(:another_column,another_column)';Invoke:
    DECLARE
      a_null CHAR(1); -- set to NULL automatically at run time
    BEGIN
      --open query
      open query using (a_null,a_null)
      --open query using A,B
      open query using A,B;
      --open query using A
      open query using A,a_null;
      --open query using B
      open query using a_null ,B;
    END;
    /Edited by: jortri on 04-dic-2008 18:34

  • Thank you. Save or print this page for your records. We'll also send you an email confirmation. Case ID: 421912520 You have chosen to call Apple later. When you're ready, call the phone number below during business hours and refer to your Case ID for fas

    Thank you.
    Save or print this page for your records. We'll also send you an email confirmation.
    Case ID: 421912520
    You have chosen to call Apple later. When you're ready, call the phone number below during business hours and refer to your Case ID for faster support.
    1-800-MY-IPHONE
    6:00 a.m. to 11:00 p.m. Central
    iPhone
    Restore or update not working as expected
    You can review this case in the Cases &amp; Repairs section.
    Additional Resources
    Return to Apple Support home.
    Visit your Support Profile.
    Create another support request.
    Your contact information
    Onechai John
    <Email Edited by Host>

    They already have your number and/or email address and maybe have sold it several times already to others as well. They also use number generators - software that will automatically create them - some work and some don't, they don't care, they send out millions and a few will fall for it and send them money. The only way to "hide" would be to change both and your password, but then it would happen again at some point.

  • Bind Variables with AND in String causing Issues in XML & Report Outputs

    Hi all,
    I'm creating a BI Publisher report (10.1.3.2) and am experiencing an issue with the interprutation of Bind Variables in the Data Template.
    Here is an example of some of the Data template
    <dataTemplate name="BudgetDataBU" description="BudgetDataBU" dataSourceRef="DLXN">
       <parameters> 
          <parameter name="p_Year" dataType="Integer" include_in_output="true"/>
          <parameter name="p_Measure" dataType="character" include_in_output="true"/>
          <parameter name="p_Currency" dataType="character" include_in_output="true"/>
          <parameter name="p_Version" dataType="character" include_in_output="true"/>
       </parameters>
       <dataQuery>
          <sqlStatement name="BusUnits">
               <![CDATA[SELECT DISTINCT CC.BUSINESS_UNIT as BUSINESS_UNIT
                        FROM   DLXN_FACT_DATA_DET FD,
                               DLXN.COST_CENTRE CC
                        WHERE FD.COST_CENTRE = CC.COST_CENTRE
                        AND FD.CAL_YEAR    = :p_Year
                        AND FD.Currency      = :p_Currency
                        AND FD.Measure      = :p_Measure
                        AND FD.Version        = :p_Version                                
                        AND CC.DLXN_VIEW = 'Delexian' ]]>
               </sqlStatement>
           <sqlStatement name="Details">
               <![CDATA[SELECT DLXN_FACT_DATA_DET.VERSION,
                               DLXN_FACT_DATA_DET.CURRENCY,
                               DLXN_FACT_DATA_DET.CAL_YEAR as CAL_YEAR,
                               SUM(nvl(DLXN_FACT_DATA_DET.JAN_AMT,0)) as JAN_AMT,
            </sqlStatement>
        </dataQuery>The problem is with the :p_Measure Bind Variable but it could just as easily be any of the other character parameters.
    The particular string value that is causing a problem is "Travel and Expenditure". I believe it is due to the "AND" in the string but this string value cannot be changed in the database to say "Travel & Expenditure".
    I have thought about using a REPLACE function in the SELECT statement but see this as an ugly solution.
    Any input greatly appreciated.
    Kind Regards,
    Gary.

    We remove this restriction ,fix included in BI Publisher July 2009 update for 10.1.3.4.x. The patch number is 8704846.

  • How execute a dynamic statement with a variable number of bind variables

    Hi all.
    I would like to execute SQL statements in a PL/SQL function.
    SQL statements must use bind variable in order to avoid parsing time. But the number of arguments depends on the context. I can have from 10 to several hundreds of arguments (these arguments are used in a 'IN' clause).
    To minimise the number of differents signature (each new signature involve a parsing), the number of argument is rounded.
    My problem is : how to set dynamicaly the bind variables ?
    Cause it is pretty simple to construct dynamicaly the SQL statement, but using an
    " OPEN .... USING var1, var2, ..., varX "
    statement, it is not possible to handle a variable nomber of bind variable.
    I am looking for the best way to do the same thing that it can be done in java/JDBC with the PreparedStatement.setObject(int parameterIndex, Object x).
    I saw the dbms_sql package and bond_variable procedure : is a the good way to do such a thing ?
    Thanks

    If the variation is only values in an IN list, I would suggest using an object type for the bind variable. This lets you have just one bind variable, regardless of how many values are in the IN list.
    The dynamic SQL ends up looking like:
    ' ... where c in (select * from table(:mylist))' using v_list;where v_list is a collection based on a SQL user-defined type that can be populated incrementally, or in one shot from a delimited list of values using a helper function.
    I use this approach all the time in dynamic searches.
    See this link for more details:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:110612348061

  • Does OraOLEDB support passing a Ref Cursor as an IN parameter of a Stored Procedure?

    We have a number of Stored Procedures that take a Cursor as an input parameter. Is it possible to call a Stored Procedure of this type with OraOLEDB? If so could you provide a quick sample using VC++/ATL?
    Thanks...

    Thank you for your reply, Yuancai. It would be very useful if the OLE DB team added such an interface to future versions of TCommand. However, for the time being what is the preferred technique for passing large amounts of data to a stored procedure? For instance we have a number of tables that have fifty or more columns. It would be awkward to call a stored procedure with this many parameters. Ideally, one would want to create a structure as a User Defined Type and pass that as a parameter.
    One approach we though of was to pass a XML string though a CLOB parameter and parse it in either a PL/SQL or Java stored procedure. However, while this approach is novel it is not standard. I've found it best to use standard techniques where possible. Any insight you could give would be appreciated.
    Thanks,
    Bryan Wood

  • Bind variables limit and overhead in single query

    HI,
    I've got query with 348 bind variables used in a way like :
    select * from table
    where
    col1 = :1 and col2 = :2
    AND apl_id in (:3, :4 ... , :348)
    is there any overhead related to such high bv number ?
    The session with that query is using about 160MB of PGA (mostly UGA about 150MB).
    Is that somehow related ?
    I'm on 9.2.0.8 EE , AIX .
    Regards
    G

    You can use an array instead of bind variables, it will give you flexibility and scalabilty,
    Example
    Note : replace sys.ODCIVarchar2List with desc sys.dbms_debug_vc2coll for 9i
    Select emp.* from  emp,
    table (sys.ODCIVarchar2List ('SCOTT','ALLEN','KING','KINGDOM'))
    where column_value=ename
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7788 SCOTT      ANALYST         7566 09-DEC-82       3000                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
    desc sys.ODCIVarchar2List
    sys.ODCIVarchar2List VARRAY(32767) OF VARCHAR2(4000)
    on 9.2.0.8  USE
    desc sys.dbms_debug_vc2coll
    sys.dbms_debug_vc2coll TABLE OF VARCHAR2(1000)HTH
    SS

  • Stored procedure and ref cursor problem

    I am trying to create a stored procedure that can be used in Crystal Reports. To do this I have to create a package and a ref cursor. My SQL is below:
    --Package
    Create or Replace Package Test_Package
    as type test_type is ref cursor;
    end;
    --Procedure
    Create or Replace Procedure Test_Proc
    (test_cursor in out test_package.test_type,
    parameter in string
    as
    begin
    open test_cursor for
    select ClientName from apbpman.cv_client where clientref = parameter;
    end;
    --When trying to execute the SP in Oracle I use:-
    set serveroutput on
    declare
    test_cursor apbpman.test_package.test_type;
    resultset test_cursor%rowtype;
    begin
    apbpman.test_proc(test_cursor,'0096');
    if not test_cursor%isopen then
    dbms_output.put_line ('OK');
    else
    dbms_output.put_line ('Not OK');
    end if;
    fetch test_cursor into resultset;
    while test_cursor%found loop
    dbms_output.put_line(resultset.ClientName);
    fetch test_cursor into resultset;
    end loop;
    end;
    Whenever this runs I receive the following error reports:
    resultset test_cursor%rowtype;
    ERROR at line 3:
    ORA-06550: line 3, column 13:
    PLS-00320: the declaration of the type of this expression is incomplete or malformed
    ORA-06550: line 3, column 13:
    PL/SQL: Item ignored
    ORA-06550: line 11, column 25:
    PLS-00320: the declaration of the type of this expression is incomplete or malformed
    ORA-06550: line 11, column 2:
    PL/SQL: SQL Statement ignored
    ORA-06550: line 13, column 24:
    PLS-00320: the declaration of the type of this expression is incomplete or malformed
    ORA-06550: line 13, column 3:
    PL/SQL: Statement ignored
    ORA-06550: line 14, column 26:
    PLS-00320: the declaration of the type of this expression is incomplete or malformed
    ORA-06550: line 14, column 3:
    PL/SQL: SQL Statement ignored
    I have tried in vain to find a resolution to this but have failed. Please help.
    Thanks,
    Paul

    Unless you are running a really old version of Oracle, any weak ref cursor can just be declared SYS_REFCURSOR. Also, you can't use a weak ref cursor for %ROWTYPE. You can test the procedure in SQL*Plus by using it to populate a refcursor variable.

  • Dynamic sql and ref cursors URGENT!!

    Hi,
    I'm using a long to build a dynamic sql statement. This is limited by about 32k. This is too short for my statement.
    The query results in a ref cursor.
    Does anyone have an idea to create larger statement or to couple ref cursors, so I can execute the statement a couple of times and as an result I still have one ref cursor.
    Example:
    /* Determine if project is main project, then select all subprojects */
    for i in isMainProject loop
    if i.belongstoprojectno is null then
    for i in ProjectSubNumbers loop
    if ProjectSubNumbers%rowcount=1 then
    SqlStatement := InitialStatement || i.projectno;
    else
    SqlStatement := SqlStatement || PartialStatement || i.projectno;
    end if;
    end loop;
    else
    for i in ProjectNumber loop
    if ProjectNumber%rowcount=1 then
    SqlStatement := InitialStatement || i.projectno;
    else
    SqlStatement := SqlStatement || PartialStatement || i.projectno;
    end if;
    end loop;
    end if;
    end loop;
    /* Open ref cursor */
    open sql_output for SqlStatement;
    Thanks in advance,
    Jeroen Muis
    KCI Datasystems BV
    mailto:[email protected]

    Example for 'dynamic' ref cursor - dynamic WHERE
    (note that Reports need 'static' ref cursor type
    for building Report Layout):
    1. Stored package
    CREATE OR REPLACE PACKAGE report_dynamic IS
    TYPE type_ref_cur_sta IS REF CURSOR RETURN dept%ROWTYPE; -- for Report Layout only
    TYPE type_ref_cur_dyn IS REF CURSOR;
    FUNCTION func_dyn (p_where VARCHAR2) RETURN type_ref_cur_dyn;
    END;
    CREATE OR REPLACE PACKAGE BODY report_dynamic IS
    FUNCTION func_dyn (p_where VARCHAR2) RETURN type_ref_cur_dyn IS
    ref_cur_dyn type_ref_cur_dyn;
    BEGIN
    OPEN ref_cur_dyn FOR
    'SELECT * FROM dept WHERE ' | | NVL (p_where, '1 = 1');
    RETURN ref_cur_dyn;
    END;
    END;
    2. Query PL/SQL in Reports
    function QR_1RefCurQuery return report_dynamic.type_ref_cur_sta is
    begin
    return report_dynamic.func_dyn (:p_where);
    end;
    Regards
    Zlatko Sirotic
    null

  • Using CRUD procedures to update data and ref cursors to return data

    Hi:
    I am currently evaluating Apex 3.x to replace an existing app that uses lots of procedures to update and return data.
    1. Is it possible to return data from a function that returns a cursor (or from a procedure that has an input/output ref cursor parameter for that matter) ? Example: Let's say I have the following function in a package:
    function get_data return sys_refcursor
    is
    l_cursor sys_refcursor;
    begin
    open l_cursor for select sysdate as field from sys.dual;
    return l_cursor;
    end;
    Can I add a page with a table that is populated based on this function? Based on my research it is not possible, but I want an APEX expert to confirm it
    2. The old application uses CRUD procedures to update date, that is for each table there are 3 procedures, insert update and delete. Question: is it possible to channel all the update, inserts and deletes through these procedures? Furthermore, in lots of cases I use sequences to populate the primary keys, and the new value is returned as output parameter. Can I retrieve the output value and use it maybe in the next page I am branching to?
    In the samples that I've seen the same form is used for insert and update. How do I distinguish between the two modes?
    3. Can you please point me to some samples that show how to do 1 & 2. The standard samples that I've seen use the automatic row processing.
    4. Could you please recommend some good books about Apex or HTML db? I found the documentation unintuitive. It is hard to picture quickly how things tie together by reading this documention. I wish the documentation was more task oriented and presented 'how to...' implement generic patterns used in web apps.
    Thank you in advance

    Hi guys
    Check out the last 2 posts in this thread for ideas on how to implement 1.
    Report on user data from LDAP
    Varad

  • DB proc - do you need to create a table to pass a ref cursor record type?

    I want to pass a limited selection of columns from a large table through a DB procedure using a REF CURSOR, returning a table rowtype:
    CREATE OR REPLACE package XXVDF_XPOS_DS021_ITEMS AS
         TYPE XXVDF_XPOS_DS021_ITEM_ARRAY
         IS REF CURSOR
         return XXVDF_XPOS_DS021_ITEM_TABLE%ROWTYPE;
    Do I need to create this dummy table?
    I can't get a TYPE to work, where the type is an OBJECT with the desired columns in it.
    So a dummy empty table will sit in the database...
    Is there another way?
    thanks!

    You can use RECORD type declaration:
    SQL> declare
      2   type rec_type is record (
      3    ename emp.ename%type,
      4    sal emp.sal%type
      5   );
      6   type rc is ref cursor return rec_type;
      7   rc1 rc;
      8   rec1 rec_type;
      9  begin
    10   open rc1 for select ename, sal from emp;
    11   loop
    12    fetch rc1 into rec1;
    13    exit when rc1%notfound;
    14    dbms_output.put_line(rec1.ename || ' ' || rec1.sal);
    15   end loop;
    16   close rc1;
    17  end;
    18  /
    SMITH 800
    ALLEN 1600
    WARD 1250
    JONES 2975
    MARTIN 1250
    BLAKE 2850
    CLARK 2450
    SCOTT 3000
    KING 5000
    TURNER 1500
    ADAMS 1100
    JAMES 950
    FORD 3000
    MILLER 1300or use, for example, VIEW to declare rowtype:
    SQL> create view dummy_view as select ename, sal from emp;
    View created.
    SQL> declare
      2   type rc is ref cursor return dummy_view%rowtype;
      3   rc1 rc;
      4   rec1 dummy_view%rowtype;
      5  begin
      6   open rc1 for select ename, sal from emp;
      7   loop
      8    fetch rc1 into rec1;
      9    exit when rc1%notfound;
    10    dbms_output.put_line(rec1.ename || ' ' || rec1.sal);
    11   end loop;
    12   close rc1;
    13  end;
    14  /
    SMITH 800
    ALLEN 1600
    WARD 1250
    JONES 2975
    MARTIN 1250
    BLAKE 2850
    CLARK 2450
    SCOTT 3000
    KING 5000
    TURNER 1500
    ADAMS 1100
    JAMES 950
    FORD 3000
    MILLER 1300 Rgds.

  • Unit testing and REF CURSORs

    Hi,
    Does anybody know when/if SQL Developer unit tests will support procedures that return reference cursors?
    Thanks
    Lee

    Support for REF CURSOR is already being considered for a future release although support will probably be under some size constraints as a REF CURSOR can obviously return a massive quantity of data in a production system which is beyond the brief of Unit Testing.

Maybe you are looking for