How to open a Ref cursor in Oracle Reports

I have a stored procedure that returns a ref cursor as an output parameter. I want to call this stored procedure in Oracle Reports After Form trigger. I am having trouble with the syntax of the output parameter. Event_record is the name of the cursor.
After Form Trigger
pkg_DEAL_WHITESHEET_CONCERTS.prc_Event_Information(:p_field_6,event_record);
Error: Event_record must be declared

Re-Write the procedure as Package Spec and Body. Declare the REFCursor in the Package Spec. Probably that helps.

Similar Messages

  • How to open new window and generate oracle report from apex

    Hi,
    I had created an application that generates PDF files using Oracle Reports, following this Guide.
    http://www.oracle.com/technology/products/database/application_express/howtos/howto_integrate_oracle_reports.html
    And I followed 'Advanced Technique', so that users can't generate PDF file by changing URL and parameters. This is done for security reasons.
    But in this tutorial, when 'Go' button is pressed, the PDF file is displayed on the same window of apex application. If so, user might close the window by mistake. In order to avoid this, another window have to be opened.
    So, I put this code in the BRANCH - URL Target. (Note that this is not in Optional URL Redirect in the button property, but the branch which is called by the button.)
    javascript:popupURL('&REPORTS_URL.quotation&P2100_REP_JOB_ID.')
    But if the button is pressed, I get this error.
    ERR-1777: Page 2100 provided no page to branch to. Please report this error to your application administrator.
    Restart Application
    If I put the code 'javascritpt ....' in the Optional URL Redirect, another window opens successfully, but the Process to generate report job is not executed.
    Does anyone know how to open new window from the Branch in this case?

    G'day Shohei,
    Try putting your javascript into your plsql process using the htp.p(); procedure.
    For example, something along these lines should do it:
    BEGIN
    -- Your other process code goes here...
    htp.p('<script type="javascript/text">');
    htp.p('popupURL("&REPORTS_URL.quotation&P2100_REP_JOB_ID.")');
    htp.p('</script>');
    END;
    What happens is the javascript is browser based whereas your plsql process is server based and so if you put the javascript into your button item Optional URL Redirect it is executed prior to getting to the page plsql process and therefore it will never execute the process. When you have it in your branch which normally follows the processes, control has been handed to the server and the javascript cannot be executed and so your page throws the error "Page 2100 provided no page to branch to"... By "seeding" the plsql process with the embedded javascript in the htp.p() procedure you can achieve the desired result. You could also have it as a separate process also as long as it is sequenced correctly to follow your other process.
    HTH
    Cheers,
    Mike

  • How to return a ref cursor from this dbms_sql?

    Hi,
    Can anyone show me how to return a ref cursor from this dbms_sql based procedure? I see 11g has a dbms_sql.to_refcursor(cursor_handle). How can this be done is 10g?
    Thx.
    CREATE OR REPLACE PROCEDURE Sample_Get_t
    p_sample_id sample.sample_id%TYPE,
    p_contract_id sample.contr_id%TYPE
    IS
    cursor_handle INT;
    sql_stmnt varchar2(500);
    rows_processed NUMBER;
    BEGIN
    sql_stmnt :=
    'SELECT
    sample_id,
    contr_id,
    rcpt_id
    FROM
    sample s
    WHERE
    s.contr_id = :1
    and s.sample_id = :2
    ORDER BY
    sample_id';
    cursor_handle := dbms_sql.open_cursor;
    dbms_sql.parse(cursor_handle, sql_stmnt, dbms_sql.native);
    dbms_sql.bind_variable(cursor_handle, ':1', p_contract_id);
    dbms_sql.bind_variable(cursor_handle, ':2', p_sample_id);
    rows_processed := dbms_sql.execute(cursor_handle);
    dbms_sql.close_cursor(cursor_handle);
    END Sample_Get_t;

    In 10 this cannot be done with dbms_sql (to my knowledge). There are a couple of other options.
    1) open the ref cursor for the dynamic statement using bind variables (or SYS_CONTEXT variables, which i prefer since they are much easier to deal with when you are dynamically adding predicates).
    declare
       wRefCursor  SYS_REFCURSOR;
    begin
       open wRefCursor for 'select * from all_objects where owner = :Logged_in_user' using user;
    end;
    /or using the context (the context will bind for you)
    declare
       wRefCursor  SYS_REFCURSOR;
    begin
       open wRefCursor for 'select * from all_objects where owner = SYS_CONTEXT(''CONTEXT_NAME'', ''VARIABLE_NAME'') ';
    end;
    /Be aware that contexts ALWAYS return varchar values, so if you are comparing to a number you should wrap it in TO_NUMBER, a date, TO_DATE and so on....
    2) change the DBMS_SQL to do an insert into a global temporary table and return the ref cursor which select's * from GTT;
    3) upgrade to Oracle 11 :)

  • Using Implicit REF Cursor in Oracle DB 12c

    For those interested in using ODP.NET implicit REF Cursors in Oracle DB 12c, the syntax is different from what was available in Oracle 11g. Here's a 12c-specific example:
    =======================
    Create or Replace PROCEDURE GetEmpAndDept
    AS
    EMPS  sys_refcursor;
    DEPTS  sys_refcursor;
    BEGIN
      OPEN EMPS for SELECT empno, ename from emp;
      dbms_sql.return_result(EMPS);
      OPEN DEPTS for SELECT deptno, dname from dept;
      dbms_sql.return_result(DEPTS);
    END;
    =======================
    // C#
    OracleConnection conn = new OracleConnection("User Id=scott; Password=tiger);
      conn.Open(); // Open the connection to the database
    // Create the command object for executing cmdTxt
      OracleCommand cmd = new OracleCommand("GetEmpAndDept", conn);
      cmd.CommandType = CommandType.StoredProcedure;
      OracleDataReader rdr = cmd.ExecuteReader();
      while(rdr.Read())
         Console.WriteLine("{0}\t{1}", rdr.GetInt32(0), rdr.GetString(1) );
      rdr.NextResult();
       while(rdr.Read())
           Console.WriteLine("{0}\t{1}", rdr.GetInt32(0), rdr.GetString(1) );

    i am using Oracle.ManagedDataAccess.dll v4.121.1.0
    Oracle Data Base 12c
    Visual Studio 2012 .net framework 4
    But if I use Unmanaged Dll I get implicit results in my .net application.

  • How to open a package body in Oracle sql developer

    How to open a package body in Oracle sql developer..any shortcut for that

    I need another way to get to my package body. I'm on a locked down system, so the only way I can reference anything is if I already know the name of it. I accidentally overwrote my text document that I was using to work on it and I closed out of the package body in sqldeveloper. There must be a command, like an alter or some such. Anyone know the old fashioned way of looking at a package?

  • Problem in opening a ref cursor.

    Hi,
    I'm getting the following error when i'm trying to open the ref cursor. PL/SQL: ORA-22905: cannot access rows from a non-nested table item
    What i'm trying to do is I'm dumping the data into pl/sql table and i want retrieving the by using a ref cursor. Please see the code and help me out.
    CREATE OR REPLACE PACKAGE CPS_RECR.pg_pool_status AS
      TYPE pool_rec IS RECORD (
       status  varchar2(50)
      ,stsno number
      ,stscode varchar2(5)
      ,candidatename varchar2(200)
      ,monyear varchar2(10)
      ,yyyymm number
      ,stscnt number
      --type rec_sts_tab is table of number ;--index by pls_integer;
      type pool_tab IS table of pool_rec index by binary_integer;
      type pool_cv is REF CURSOR return pool_rec;
    FUNCTION pool_status_query(p_start_date in date,p_end_date in  date,p_invitedtopoolbit  in number,p_showedForPoolBit in  number)
       RETURN pool_tab;--pool_cv ;
      cursor cur_pool(p_start_date date,p_end_date date,p_invitedtopoolbit number,p_showedForPoolBit number)
      is
         SELECT   distinct to_char(date1,'yyyymm')yearmonth
                  FROM acs100data a,
                     acs100_candidate_verification b,                
                     acs100_candidate_pool d
                 WHERE UPPER (a.basic_email) = UPPER (b.email)
                 AND (b.candidate_status IN ('FORL', 'FWRT') or BITAND (b.candidate_status_bit, 4 ) > 0
                  or BITAND (b.candidate_status_bit, 2) > 0)                         
                 AND d.pool_id = b.pool_id
                 AND pool_date BETWEEN p_start_date AND p_end_date
                 AND is_tentative_date IS NULL  ;
      cursor cur_name(p_yyyymm varchar2,p_cond number,p_start_date date,p_end_date date)
      is
      select *
      from (select distinct (case
                                when p_cond = 0 and b.candidate_status = 'FORL'
                                   then (last_name || first_name)
                                when p_cond = 1 and b.candidate_status = 'FWRT'
                                   then (last_name || first_name)
                                when p_cond = 2
                                and bitand (b.candidate_status_bit, p_cond) > 0
                                   then (last_name || first_name)
                                when p_cond = 4
                                and bitand (b.candidate_status_bit, p_cond) > 0
                                   then (last_name || first_name)
                             end
                            ) candidatename
                       from acs100data a,
                            acs100_candidate_verification b,
                            acs100_candidate_pool d
                      where upper (a.basic_email) = upper (b.email)
                        and d.pool_id = b.pool_id
                        and pool_date between p_start_date and p_end_date
                        and to_char (date1, 'yyyymm') = p_yyyymm
                        and is_tentative_date is null)
    where candidatename is not null;  
    END pg_pool_status;
    CREATE OR REPLACE PACKAGE BODY CPS_RECR.pg_pool_status
    AS
       FUNCTION pool_status_query (
          p_start_date         IN   DATE,
          p_end_date           IN   DATE,
          p_invitedtopoolbit   IN   NUMBER,
          p_showedforpoolbit   IN   NUMBER
          RETURN pool_tab--pool_cv
       IS
          tab_pool    pool_tab;
          temp_rf    pool_cv;
          n_index     NUMBER         := 1;
          --rec_sts_data  rec_sts_tab;
          n_stscnt    NUMBER;
          vc_status   VARCHAR2 (100);
          vc_label  varchar2(1000);
          vc_name  varchar2(100);
       BEGIN
          tab_pool.DELETE;
          vc_label :='Opening Pool cursor';
          FOR rec_pool IN cur_pool (p_start_date,
                                    p_end_date,
                                    p_invitedtopoolbit,
                                    p_showedforpoolbit
          LOOP
              if cur_pool%notfound then
                exit;
              end if;
             vc_label :='Opening p_cond cursor';
             FOR p_cond IN 0 .. 3
             LOOP
                n_stscnt := 0;
                vc_status := NULL;
                begin
                    SELECT   SUM
                                (NVL
                                    (COUNT
                                        (CASE
                                            WHEN p_cond = 0
                                            AND b.candidate_status = 'FORL'
                                               THEN (last_name || first_name)
                                            WHEN p_cond = 1
                                            AND b.candidate_status = 'FWRT'
                                               THEN (last_name || first_name)
                                            WHEN p_cond = 2
                                            AND BITAND (b.candidate_status_bit,
                                                        p_cond) > 0
                                               THEN (last_name || first_name)
                                            WHEN p_cond = 4
                                            AND BITAND (b.candidate_status_bit,
                                                        p_cond) > 0
                                               THEN (last_name || first_name)
                                         END
                                     0
                                ) cnt,
                             DECODE (p_cond,
                                     0, 'FAILED WRITTEN TEST',
                                     1, 'FAILED **** TEST',
                                     2, 'Invited for Pool',
                                     4, 'Showed up for Pool'
                                    ) status
                        INTO n_stscnt,
                             vc_status
                        FROM acs100data a,
                             acs100_candidate_verification b,
                             acs100_candidate_pool d
                       WHERE UPPER (a.basic_email) = UPPER (b.email)
                         AND d.pool_id = b.pool_id
                         AND pool_date BETWEEN p_start_date AND p_end_date
                         AND TO_CHAR (date1, 'yyyymm') = rec_pool.yearmonth
                         AND is_tentative_date IS NULL
                    GROUP BY candidate_status,
                             b.candidate_status_bit,
                             DECODE (p_cond,
                                     0, 'FAILED WRITTEN TEST',
                                     1, 'FAILED **** TEST',
                                     2, 'Invited for Pool',
                                     4, 'Showed up for Pool'
                  exception
                     when no_data_found
                     then
                        n_stscnt :=0;
                        vc_status :=null;
                 end;
                vc_label :='Opening name cursor';         
                FOR rec_name IN cur_name (rec_pool.yearmonth,
                                          p_cond,
                                          p_start_date,
                                          p_end_date
                LOOP
                   if cur_name%notfound then
                   exit;
                   end if;
                   tab_pool (n_index).yyyymm := rec_pool.yearmonth;
                   tab_pool (n_index).stscnt := n_stscnt;
                   tab_pool (n_index).status := vc_status;
                   tab_pool (n_index).candidatename := rec_name.candidatename;
                   dbms_output.put_line('tab_pool(n_index).yyyymm  : '||tab_pool(n_index).yyyymm);
                   dbms_output.put_line('tab_pool(n_index).stscnt : '||tab_pool(n_index).stscnt);
                   dbms_output.put_line('tab_pool(n_index).status : '||tab_pool(n_index).status);
                   dbms_output.put_line('tab_pool(n_index).candidatename : '||tab_pool(n_index).candidatename);
                   vc_name :=rec_name.candidatename;
                END LOOP;
                n_index := n_index + 1;
             END LOOP;
          END LOOP;      
          RETURN tab_pool;
       exception
         when others
         then
             dbms_output.put_line('error :'||vc_label||'--'||  vc_name); 
       END;
    END pg_pool_status;
    ---run script
    DECLARE
      RetVal CPS_RECR.PG_POOL_STATUS.pool_tab;
      P_START_DATE DATE;
      P_END_DATE DATE;
      P_INVITEDTOPOOLBIT NUMBER;
      P_SHOWEDFORPOOLBIT NUMBER;
    temp_cv CPS_RECR.PG_POOL_STATUS.pool_cv;
    BEGIN
      P_START_DATE := to_date('09/01/2008','mm/dd/yyyy');
      P_END_DATE := to_date('09/30/2008','mm/dd/yyyy');
      P_INVITEDTOPOOLBIT := 2;
      P_SHOWEDFORPOOLBIT := 4;
      open temp_cv for select * from  table((CPS_RECR.PG_POOL_STATUS.POOL_STATUS_QUERY ( P_START_DATE, P_END_DATE, P_INVITEDTOPOOLBIT, P_SHOWEDFORPOOLBIT )) );
      end loop;
    exception
       when others
       then
          dbms_output.put_line(sqlerrm);
    END;

    Satyaki,
    It doesn't help me out. I'm worndering one of code sample is working fine. i didn't my current is giving the problem.
    FYI, please see the some code i followed.
    SQL> Create or replace PACKAGE cv IS
      2     type comp_rec is RECORD
      3               (deptno number,
      4                ename  varchar(10),
      5                compensation number);
      6     type comp_tbl IS table of comp_rec;
      7     function get_coll return comp_tbl pipelined;
      8     temp_tbl comp_tbl := comp_tbl();
      9     type comp_cv is REF CURSOR return comp_rec;
    10  end;
    11  /
    Package created.
    SQL> Create or replace PACKAGE body cv IS
      2     function get_coll return comp_tbl pipelined
      3     is
      4     begin
      5      for i in 1..temp_tbl.count loop
      6       pipe row(temp_tbl(i));
      7      end loop;
      8      return;
      9     end;
    10  end;
    11  /
    Package body created.
    SQL> declare
      2     temp_cv cv.comp_cv;
      3     rc cv.comp_rec;
      4  begin
      5           cv.temp_tbl.delete;
      6           cv.temp_tbl.extend;
      7    cv.temp_tbl(1).deptno:=10;
      8    cv.temp_tbl(1).ename:='1223';
      9    cv.temp_tbl(1).compensation:=10;
    10  
    11          -- erroring out
    12   open temp_cv for select * from  table(cv.get_coll);
    13          fetch temp_cv into rc;
    14          dbms_output.put_line('Deptno is ' || rc.deptno);
    15          dbms_output.put_line('ename is ' || rc.ename);
    16  end;
    17  /
    Deptno is 10
    ename is 1223
    PL/SQL procedure successfully completed.

  • How to set default print orientation in oracle reports 6i?

    Can anyone please help how to set default print orientation of Oracle Reports 6i? Currently document is printed in Portrait orientation, but I need to print it in Landscape orientation. Is this possible?

    It is solved now. Go to Layout Model -> Main Section, Press F4. In the property pallet select the Orientation that is required to be selected when print is taken for that report.

  • Passing Ref Cursor to Oracle Stored Procedure Via C#

    Hi all,
    I am new to oracle and stuck with an issue. I have three insert stored procedures for three different tables. Two of them have multiple rows to be inserted, which is currently done via iterating through each row and insert to db in C# code. My requirement is to merge these three procedures in one and instead of iterating from C# code send table rows as (ref cursor or collection) to procedure and the procedure will handle the rest.
    I read that ref cursor only works if you're data is in database as it reference the memory but in my case data is build on client side.
    I am using Oracle 11i and ASP.Net 2.0
    Can any help me on this please?
    Edited by: 929463 on Apr 23, 2012 12:38 AM

    929463 wrote:
    I am new to oracle and stuck with an issue. I have three insert stored procedures for three different tables. Two of them have multiple rows to be inserted, which is currently done via iterating through each row and insert to db in C# code. My requirement is to merge these three procedures in one and instead of iterating from C# code send table rows as (ref cursor or collection) to procedure and the procedure will handle the rest.Why a single procedure? How is the procedure to determine the target table to insert the data into? And please - no dynamic SQL as that is 99% of the time wrong.
    A ref cursor is something that PL/SQL creates - with the purpose of passing the cursor handle to your code. This enables the actual SQL statement for that cursor to be moved from client code, into a PL/SQL stored proc. It abstracts the client from having to understand SQL, understand the data model and so on. All clients use the same PL/SQL proc and thus the same code for creating that cursor. Thus no issue of some clients getting it half right or half wrong and dealing with data inconsistencies between clients.
    The PL/SQL proc can be tuned and optimised, modified for catering for data model changes and so on. Without your client code having to be even recompiled as it is isolated against these server changes.
    For all other interaction (running PL/SQL code, doing insert/update/delete/etc SQL statements), you need to create the cursor yourself in your code.
    Also, the SQL engine only sees cursors. There are no differences between cursors. The client (e.g. PL/SQL) can call it a reference cursor, or an implicit cursor, or a DBMS_SQL cursor.. the SQL engine does not know that and does not care.
    A ref cursor is simply a special type of client interface to a SQL cursor, allowing PL/SQL to create that SQL cursor and then pass the handle of that SQL cursor to other code to consume that cursor.
    Okay, so if you want to insert data, you need in your code to create a cursor. This can be a SQL INSERT cursor - the actual insert statement. Or it can be a PL/SQL call - an anonymous PL/SQL code block that calls a stored proc that performs the insert (after applying validation and business logic).
    The cursor will have one or more bind variables. Your client will pass values for these variables and the server-side code (SQL or PL/SQL) will be executed using this as variable data.
    You can for example create a cursor as follows:
    begin
      DoFunkyInsert( :1, :2, :3 );
    end;
    {code}
    3 bind variables are expected. You can now in the client build an array for each of these variables, containing a 100 values each (total of a 100 rows to insert). Do a single execute of the cursor, and tell Oracle that the bind is actually a 100 element array.
    The complete array ships to Oracle - Oracle opens a loop and execute the cursor for each element in the array.
    This is called bulk binding.
    An alternative approach is to define the bind variable as a collection (a non-scalar value). And then code the PL/SQL procedure to open a loop and iterate through the collection/array, inserting a row per iteration.
    The binding itself is more complex as your code know needs to understand Oracle object types and be able to define an array/collection that is a valid Oracle non-scalar data type.
    The +Oracle Call Interface+ (OCI) is quite flexible in this regard. However, as you work via an abstraction layer (e.g. ADO, OleDB, ODBC, etc) your code is subject to whatever functionality this abstraction layer makes available to your code. And this is seldom includes all the power, functionality and flexibility of the (more complex) OCI itself.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

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

  • How to handle the ref cursor which is returning "no rows"

    I have written a function which is returning the REF CURSOR. But in one situation the REF CURSOR returns "no rows selected". To handle this situation an exception is raised "when no data found". But i dont know in this situation how should NULL cursor be returned through this function. Since I want to call this function in another procedure so something should be returned through this function by means of ref cursor. But since i am not able to handle this "no rows selected" situation i am not able move further.
    Thanks in advance........

    I agree.
    You would simply process the returned ref cursor irrespective of any rows actually returned in the cursor or not. You would be able to do at least one FETCH from the cursor (even if it does not actually contain any rows) and then determine the %NOTFOUND status to do the rest of the processing.
    SQL> variable cur refcursor
    SQL> exec open :cur for select * from scott.emp where rownum = 1 ;
    PL/SQL procedure successfully completed.
    SQL> print cur
         EMPNO ENAME      JOB              MGR HIREDATE           SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-1980        800                    20
    1 row selected.
    SQL>
    SQL> exec open :cur for select * from scott.emp where 1 = 2 ;
    PL/SQL procedure successfully completed.
    SQL> print cur
    no rows selected
    SQL>
    SQL> SET SERVEROUTPUT ON
    SQL> DECLARE
      2      rec scott.emp%ROWTYPE;
      3      bol BOOLEAN;
      4      cur sys_refcursor;
      5  BEGIN
      6      OPEN cur FOR
      7          SELECT * FROM scott.emp WHERE 1 = 2; /* assume this is your function call returning a ref cursor */
      8      bol := FALSE;
      9      LOOP
    10          FETCH cur
    11              INTO rec;
    12          EXIT WHEN cur%NOTFOUND;
    13          --
    14          -- process the data here
    15          --
    16          bol := TRUE;
    17      END LOOP;
    18      CLOSE cur;
    19      IF (bol)
    20      THEN
    21          dbms_output.put_line('At least one row was found');
    22      ELSE
    23          dbms_output.put_line('No rows were selected');
    24      END IF;
    25  END;
    26  /
    No rows were selected
    PL/SQL procedure successfully completed.
    SQL>

  • Odd error while opening a ref cursor

    Hi.
    I have a procedure in a package that has both in and out parameters. One of those out parameters is a ref cursor. The procedure creates a dynamic query and then executes it, then it opens the cursor:
    PROCEDURE PROC(
    A IN VARCHAR2,
    B IN VARCHAR2,
    C OUT TYPES.cursorType; --(TYPES is a package whose only use is to declare a cursor type)
    ) IS
    --DECLARATIONS
    OPEN C FOR 'SELECT A, B, C, D...';
    END;
    When I execute the package in an anonymous block it throws the error:
    ORA-00938: not enough arguments for function, just in the line where the cursor is being opened.
    Any ideas?

    is everything defined correctly?
    create or replace package types  as
      type cursorType is ref cursor;
    end types;
    SQL> set serveroutput on
    SQL> declare
      2 
      3    ref_C types.cursorType;
      4   
      5    v_a varchar2(1);
      6    v_b varchar2(1);
      7    v_c varchar2(1);
      8    v_d varchar2(1);
      9   
    10    procedure Proc (a in varchar2
    11                   ,b in varchar2
    12                   ,C out types.cursorType) as
    13 
    14      begin
    15        open C for 'select :1, :2, ''c'', ''d'' from dual' using a, b;
    16    end  Proc;
    17  begin
    18 
    19 
    20    Proc('a', 'b', ref_C);
    21   
    22    fetch ref_C into v_a, v_b, v_c, v_d;
    23    if (ref_C%found) then
    24      dbms_output.put_line(v_a);
    25      dbms_output.put_line(v_b);
    26      dbms_output.put_line(v_c);
    27      dbms_output.put_line(v_d);
    28    end if;
    29   
    30   
    31  end;
    32  /
    a
    b
    c
    dP;
    Edited by: bluefrog on Feb 18, 2010 6:07 PM

  • How to descrbe a ref cursor from a PL/SQL prog?

    Hi,
    here is a sample of the my problem
    let suppose a table country :
    create table country(country_code VARCHAR2(3), country_name VARCHAR2(50));
    then a package containing different procedures among them, this one :
    PL/SQL prog
    create or replace package country_pkg as
    type rec1 is ref cursor return country%rowtype;
    Procedure get_all_countries(rec in out rec1);
    blablabla ...
    END country_pkg;
    in the package body, i have the following code :
    create or replace package body country_pkg as
    procedure get_all_countries(rec IN OUT rec1) is
    begin
    if not rec%open then
    open rec for select * from country order by country_name;
    end if;
    exception
    when NO_DATA_FOUND then
    close rec;
    end get_all_countries;
    blablabla....
    end;
    Then in the C program
    (*proc)->request->command = "begin get_all_countries(:rec); end;"
    checkerr(&connect, \
         OCIStmtPrepare(connect->stmthp,\
         connect->errhp,\
         (*proc)->request->command,\
         strlen((*proc)->request->command),\
         OCI_NTV_SYNTAX, OCI_DEFAULT));
    checkerr(&connect, \
         OCIHandleAlloc((dvoid*)(connect->envhp),\
         (dvoid**) &((*proc)->stmthp), OCI_HTYPE_STMT,
    (size_t) 0,\
         (dvoid**) 0));
    bndhp = (OCIBind**) g_malloc0((*proc)->argnum*sizeof(OCIBind*));
    for(i = 0; i < (*proc)->argnum; i++)
    switch ((*proc)->desc->type)
    case 102:
    checkerr(&connect,
    OCIBindByPos(connect->stmthp, &bndhp[j],
    connect->errhp,
         i+1,&((*proc)->stmthp), (sb4) 0,
         SQLT_REF, (dvoid*) 0, (ub2*) 0, (ub2*) 0,
    (ub4) 0,
         (ub4*) 0, (ub4) OCI_DEFAULT));
    default:
    some code ....
    checkerr(&connect, \
         OCIStmtExecute(connect->svchp, connect->stmthp,\
         connect->errhp, 1, (ub4) 0, (OCISnapshot*) 0,\
         (OCISnapshot*) 0, OCI_DEFAULT));
    parm_status = OCIParamGet(connect->stmthp, OCI_HTYPE_STMT,connect->errhp, (dvoid**)&arg, 0);
    while(parm_status == OCI_SUCCESS)
    OCIAttrGet((dvoid*) arg, OCI_DTYPE_PARAM,
    (dvoid*)type,0, (ub4) OCI_ATTR_NUM_PARAMS,
    connect->errhp);
    counter++;
    parm_status = OCIParamGet(connect->stmthp,
    OCII_HTYPE_STMT,connect->errhp,
    (dvoid**)&arg, counter);
    This piece of code doesn't work as 'arg' is always NULL
    and OCIParamGet retruns OCI_SUCCESS.
    I'm certainly missing something but I don't see what. Could anyone help me to get that piece of code working?
    regards,
    Raphael

    unfortunately, not yet!
    I dropped the matter for now, I'll come back on it later.
    On your side, let me know if you find something interesting on that topic by posting a message here.

  • How to open page with cursor in a set location

    We have a page for a login, and I want the page to open with the cursor positioned in that location.  Below is the code we have which seems like it should work but it doesn't.  This was a page someone else created and as a new user of DreamWeaver, I don't know how it was created to start with so don't know how to fix (or start over).  Any advice?  Thanks
    <!--
       function position_cursor()
         document.Login.txtUserName.focus();
    //-->
    <td height="47" valign="bottom" width="187"><input type="text" name="txtUserName" />                    </td>

    I didn't know how much to copy, but I hope I caught what you were looking for.
    </style>
    </head>
    <p></
    <body bgcolor="#000000" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="goforit();position_cursor()">
    <p align="center"><img src="images_08/08banner.jpg" alt="OACS Banner" width="777" height="175" border="3"></p>
    <tr>
          <td>
             <table width="780" border="2" align="center" cellpadding="0" cellspacing="0" bordercolor="#000033">
    <tr>
              <td bgcolor="#A0B8B8" width="175" valign="top" align="center"><p> </p>
                 <p><a href="08index.html"><img src="images_08/returntoOACS.gif" alt="Return to OACS Home Page" width="139" height="123" border="0"></a
                    ></p></td>
              <td width="605" align="left" bgcolor="#FFFFFF"><p align="center"><br />
                      <script>      
      </script>
              </p>
                  <form name="Login" method="post" action="../asp/check_user.asp">
                    <div align="center"> <font size="6" face="Arial, Helvetica, sans-serif"><b>Login to OACS</b></font><br />
                        <br />
                    </div>
                    <table width="301" height="138" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#333333" bgcolor="#A0B8B8">
                      <tr>
                        <td align="right" height="47" valign="bottom" width="114"><font face="Arial, Helvetica, sans-serif"><strong>User name: </strong></font> </td>
                        <td height="47" valign="bottom" width="187"><input type="text" name="txtUserName" />                    </td>
                      </tr>
                      <tr>
                        <td align="right" width="114"><font face="Arial, Helvetica, sans-serif"><strong>Password: </strong></font> </td>
                        <td width="187"><input type="password" name="txtUserPass" />                    </td>
                      </tr>
                      <tr>
                        <td align="right" height="44" width="114"> </td>
                        <td height="44" width="187"><input type="submit" name="Submit" value="Enter" />
                  <input type="reset" name="Submit2" value="Reset" />                    </td>
                      </tr>
                    </table>
                    <p align="center"><br />
                       <font size="4" face="Arial, Helvetica, sans-serif">Please
                        use all lowercase letters for the password.</font></p>
                  </form>
                  <p> </p>
                  <p> </p>
                  <p> </p>
                  <p> </p>
                  <p> </p>
                  <p> </p>
                  <p> </p></td>
            </tr>
          </table></div></td>
    </tr>
      </table>
      <br />
       <br />
    </div>
    </body>
    </html>          

  • How to open the second VM in Oracle 11gR2 2-nodes RAC system ?

    Folks,
    Hello. I have been installing Oracle Database 11gR2 RAC system using 2 nodes that are 2 Virtual Machines (rac1 and rac2) on the top of VMPLayer 3.
    I follow the tutorial http://appsdbaworkshop.blogspot.com/2011/10/11gr2-rac-on-linux-56-using-vmware.html to do.
    The original Virtual Machine rac1 has run correctly. I configure rac1 network (eth0 and eth1) by opening VM rac1 and using command "[root@rac1\] #neat" as root user to invoke the network configuration.
    For the second Virtual Machine rac2, I simply copy all files in "C:\VM\rac1" into "C:\VM\rac2". Then I have done the following:
    1) In the directory "C:\VM\rac2", rename "rac1.vmx" to "rac2.vmx".
    2) Change display name from "rac1" to "rac2" in the file "rac2.vmx".
    The next thing to do for rac2 is to open the Virtual Machine rac2 and configure its network (eth0 and eth1) by using the command "[root@rac2\]#neat" as root user.
    But by this step, I don't understand how to open the Virtual Machine rac2 so that can configure its network (eth0 and eth1).
    Can any folk tell me how to open the VM rac2 to configure its network by this step ?

    Hi,
    But by this step, I don't understand how to open the Virtual Machine rac2 so that can configure its network (eth0 and eth1)."rac2" is a new virtual machine after you copied and changed the display name and you need to add this in the vmware enventory (I am talking about vmware server and vmware player should have the same way as it is supposed to run multiple vritual machines on your PC). Then it will be visible it to you. Now start this new machine and edit the network configuration.
    Salman

  • How to out Dynamic ref cursor from Procedure to Forms

    Hi
    I am trying to out Dynamic ref cursor from Procedure to Forms, But I am unable to do so. however cursor return the value within procedure but I am failed to capture the same in Forms
    Pl advice suggestion if any, Here I am attaching full procedure for reference
    CREATE PACKAGE winepkg
    IS
    TYPE wine IS RECORD ( mynumber number);
    /* Define the REF CURSOR type. */
    TYPE wine_type IS REF CURSOR RETURN wine;
    END winepkg;
    CREATE procedure find_wine
    (col1_in in number,
    c1 out winepkg.wine_type) as
    vsql varchar2(1000);
    cur sys_refcursor;
    x number;
    BEGIN
    vsql:='select bo_id from bo_details where bo_details.bo_id = '||col1_in ;
    open cur for vsql;
    c1:=cur;
    --fetch c1 into x;
    --dbms_output.put_line(x);
    END find_wine;
    In front end forms
    Declare
    TYPE F is REF CURSOR;
    CUR_F F;
    rec number;
    Begin
    break;
    find_wine( 1601480000011078,cur_f ) ;
    Loop
    fetch cur_f into rec ;
    Message(rec ) ;pause;
    exit when cur_f%notfound ;
    End loop ;
    exception
    when others then
    Message(sqlerrm) ;pause;
    End ;

    yo can use
    declare
    c_cursor EXEC_SQL.CursType;
    v_stmt varchar2(2000) = 'select a, b, c from mytab where cond1'; -- you can create this value dynamically
    begin
    c_cursor := Exec_SQL.Open_cursor;
    EXEC_SQL.PARSE(c_articulos, v_stmt);
    EXEC_SQL.DEFINE_COLUMN(c_articulos,1, v_colchar1, 30);
    EXEC_SQL.DEFINE_COLUMN(c_articulos,2, v_colchar2, 15);
    EXEC_SQL.DEFINE_COLUMN(c_articulos,3, v_colchar3, 30);
    v_exec := EXEC_SQL.EXECUTE(c_cursor);
    WHILE EXEC_SQL.FETCH_ROWS(c_cursor) > 0 LOOP
    EXEC_SQL.COLUMN_VALUE(c_cursor,1,v_colchar1);
    EXEC_SQL.COLUMN_VALUE(c_c_cursor,2,v_colchar2);
    EXEC_SQL.COLUMN_VALUE(c_c_cursor,3,v_colchar3);
    assign_values_to_block;
    END LOOP;
    EXEC_SQL.CLOSE_CURSOR(c_cursor);
    end;
    and WORKS IN FORMS 6

Maybe you are looking for

  • Crystal report SQL Command and using IN

    Post Author: geozuh CA Forum: Crystal Reports Does any one know how to get a multiple value prompts to work in Crystal report SQL Commands? I have an extremely large database and do not want to pull back all the records to the report. I know I can do

  • Cancel button to display confirmation dialog in an edittable form

    Hi everyone. I have got a requirement that in my edittable form, I need to show confirmation popup before canelling the page and discarding all the changes. But, before showing that dialog, I need to figure out if any changes happened or not? As usua

  • HT4436 How can I export all my icloud contacts to Outlook?

    How can I export all my icloud contacts to Outlook?

  • Enlarge icons in finder

    I can't for the life of me find the setting that I used to have in Mavericks whereby when I viewed a folder in the finder as icon view i.e. a load of photos, there used to be a slider in the button right corner of that window so I could increase and

  • Printer problems with mountain lion

    I have just purchased a new Epson printer and it will not setup with my OSX 10.8.2