Made Oracle 6i LOV with ref cursor returned by a function of database

Hi all

I want to dynamically create a LOV in oracle forms 6i using the value of ref cursor returned by the function of database.

is this possible?

Using loop, I could able to display the values returned by the ref cursor, but how can I assign these values in the LOV?

You will need to loop through your REF Cursor and assign each value to a group of registration of forms and then assign the Group Record to your LOV.  Take a look at the built-ins CREATE_GROUP, ADD_GROUP_COLUMN and ADD_GROUP_ROW in the help system of forms for more information about how to use these built-ins and examples of how to use them.

Craig...

Tags: Oracle Development

Similar Questions

  • How to read my ref cursor return user defined cursor type

    Hello
    I have the types defined as follows:
    TYPE MY_RECORD IS RECORD (
    COL1 TABLE1.COL1%TYPE,
    COL2 TABLE1.COL2%TYPE
       );
    
    TYPE MY_CURSOR IS REF CURSOR
    RETURN MY_RECORD;
    It is used as a return type in a stored procedure.
    I have a pl/sql block, where I make a call to MS that returns this cursor.
    How to read individual values for SP?
    SQL> create or replace package pkg
    as
       type my_record is record (col1 emp.empno%type, col2 emp.ename%type);
    
       type my_cursor is ref cursor
          return my_record;
    
       procedure p (cur out my_cursor);
    end pkg;
    /
    Package created.
    
    SQL> create or replace package body pkg
    as
       procedure p (cur out my_cursor)
       as
       begin
          open cur for
             select   empno, ename
               from   emp
              where   rownum <= 2;
       end p;
    end pkg;
    /
    Package body created.
    
    SQL> declare
       cur     pkg.my_cursor;
       e_rec   pkg.my_record;
    begin
       pkg.p (cur);
    
       loop
          fetch cur into   e_rec;
    
          exit when cur%notfound;
          dbms_output.put ('Empno: ' || e_rec.col1);
          dbms_output.put_line ('; Ename: ' || e_rec.col2);
       end loop;
    
       close cur;
    end;
    /
    Empno: 7369; Ename: SMITH
    Empno: 7499; Ename: ALLEN
    PL/SQL procedure successfully completed.
    
  • PL/SQL - Call Out Ref Cursor returned by a stored procedure

    Hello

    I am creating a procedure where a Ref Cursor is defined as an OUT parameter, my question is how to shout that the Ref Cursor when I run for example here is how I want to call my EXEC sql command:

    EXEC film_not_in_stock (2,2,vcur);

    Here is the procedure:

    CREATE OR REPLACE PROCEDURE film_not_in_stock (p_film_id in NUMBER, p_store_id number, vcur ON SYS_REFCURSOR)

    IS

    News sys_refcursor;

    v_cur inventory.inventory_id%TYPE--ou is the same type of column inventory_id

    v_cur sys_refcursor;

    BEGIN

    Heart OPEN to SELECT inventory_id

    INVENTORY

    WHERE film_id = p_film_id

    AND store_id = p_store_id

    AND inventory_id NOT IN (SELECT inventory_in_stock (inventory_id) FROM dual);

    News of FETCH in v_cur;

    OUTPUT WHEN heart % NOTFOUND;

    END;

    /

    I know there are typos in the procedure, you will appreciate if you can help me to put it right.

    Thank you very much!

    Tonya.

    In fact, based on your previous post, function inventory_in_stock returns 0 or 1. If so, there are:

    CREATE OR REPLACE

    PROCEDURE film_not_in_stock)

    p_film_id in NUMBERS

    p_store_id in NUMBERS

    p_cur ON SYS_REFCURSOR

    )

    IS

    News sys_refcursor;

    v_cur inventory.inventory_id%TYPE--ou is the same type of column inventory_id

    v_cur sys_refcursor;

    BEGIN

    OPEN p_cur

    FOR

    SELECT inventory_id

    INVENTORY

    WHERE film_id = p_film_id

    AND store_id = p_store_id

    AND inventory_in_stock (inventory_id) = 0;

    News of FETCH in v_cur;

    OUTPUT WHEN heart % NOTFOUND;

    END;

    /

    SY.

  • How to perform procedures with REF CURSOR &amp; PLSQL settings table in SQL Dev?

    I have 3 SQL Developer. I create a procedure with a set of tables/PL/SQL as an input parameter and a SYS_REFCURSOR as output parameter.

    When I press the green arrow (Run button) block the dialog box run PL/SQL PL/SQL has no place at the PL/SQL table with records of entry and also to see the output of the SYS_REFCURSOR.

    I get the error ORA-06550 and many other errors when I run the present.

    How to do this please?

    In the debug code, lose the ABS. Prefix the SYS_REFCURSOR QC_SQL_DEVELOPER_TEST.
    Also, do not use same name of your settings on your bind variable (so e.g.: OUT_REF_CURSOR).
    REF CURSOR is supported output types, so you will get the output of their share in the output tab.
    However the output system does not recognize your own types as your PL/SQL table. You need to write an exit procedure yourself, indexing correctly, using the DBMS_OUTPUT.

    Have fun
    K.

  • Error when you work with Ref Cursor

    Hi, I tried the following, but the err
    DECLARE
     TYPE ref_nm IS REF CURSOR;
     vref REF_NM;
     vemp emp%rowtype;
    BEGIN
     OPEN vref FOR SELECT ename ,sal FROM EMP;
     LOOP
      FETCH vref INTO vemp;
      EXIT WHEN vref%NOTFOUND;
        DBMS_OUTPUT.PUT_LINE ( vemp.ename ||','||vemp.sal ); 
     END LOOP;
      CLOSE vref;
    END;
    Error is
    ORA-06504: PL/SQL: Return types of Result Set variables or query do not match 

    Use you this structure as a buffer of extraction:
    PEMV emp % rowtype;

    This structure contains the whole line of EMP - all columns.

    That's what you're looking for cursor - 2 columns (not the whole line):
    Vref OPEN for SELECT ename, sal of EMP;

    You can not expect from PL/SQL to find out how to move the 2 column values in a structure that has more than just 2 columns. The error message is quite clear about this - read and think what is transport of the error.

  • How to run the packaged procedure with Ref Cursor

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

    Thank you

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

    declare
      lOutCursor CURSPKG.T_CURSOR;
    begin
      CURSPKG.OPEN_ONE_CURSOR(, lOutCursor);
    end;
    
  • NamedStoredProcedure with Ref Cursor output

    I would like to install a NamedStoredProcedureQuery who can receive results of a cursor, and I wonder if it's possible.

    So I have my procedure:

    procedure test_proc (t_cursor ON ref_cursor)
    is
    Start
    Open the t_cursor for
    Select * from enrolment;
    end;

    and my NamedStoredProcedureQuery:

    @NamedStoredProcedureQuery (name = "TEST_REF_CURSOR", procedurename = "TEST_REF_CURSOR.test_proc", returnsResultSet = true,
    parameters = {@StoredProcedureParameter (queryParameter = "t_cursor", name = "t_cursor", direction = Direction.OUT_CURSOR, type = Enrolment.class)})


    So I try to call my Proc with:

    Query query = em.createNamedQuery ("TEST_REF_CURSOR");
    List results = query.getResultList ();

    and I get a oh so helpful error:


    Inner exception: java.sql.SQLException: ORA-00900: invalid SQL statement

    Error code: 0
    Call: BEGIN TEST_REF_CURSOR.test_proc (t_cursor = >?); END;
    link = > [= > t_cursor]


    I'm doing something wrong or should I use StoredProcedureCall instead?

    It should work.

    The question seems to be

    returnsResultSet = true,

    delete it, or set it to false.

    ---
    James: http://www.eclipselink.org

  • Ref cursor returns null

    I have a proc as below.

    Input value will be in the format 123,9092

    But even if the database is set to, the da returns null

    Help, please

    PROCEDURE GET_HIP_MED_CENTER_DESCR (p_in_provnum in varchar2 ,p_out_HIP_MED_CENTER OUT ref_cursor)is
       p_provnum varchar2(100);
             BEGIN
             
    SELECT '''' || REPLACE(p_in_provnum,',',''',''') || '''' into p_provnum FROM DUAL;
             
             dbms_output.put_line(p_provnum);
             
      
     
             OPEN p_out_HIP_MED_CENTER FOR
              SELECT distinct PROVNUM,MED_CENTER
               FROM hip.ref_hip_med_centers 
               where  PROVNUM IN (p_provnum) AND MED_CENTER_DIPLAY is not null 
               order by MED_CENTER asc;
           
         end;
               

    You need the dynamic SQL statement:

    PROCEDURE GET_HIP_MED_CENTER_DESCR (p_in_provnum in varchar2 ,p_out_HIP_MED_CENTER OUT ref_cursor)is
       p_provnum varchar2(100);
             BEGIN
    
    SELECT '''' || REPLACE(p_in_provnum,',',''',''') || '''' into p_provnum FROM DUAL;
    
             dbms_output.put_line(p_provnum);
    
             OPEN p_out_HIP_MED_CENTER FOR
              'SELECT distinct PROVNUM,MED_CENTER
               FROM hip.ref_hip_med_centers
               where  PROVNUM IN ('  || p_provnum || ') AND MED_CENTER_DIPLAY is not null
               order by MED_CENTER asc';
    
         end;
               
    

    However, I would suggest using the collection.

    SY.

  • 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

  • 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

  • using plsql table and ref cursor in oracle's 10 g

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

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

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

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


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

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

    END bonus_pkg;

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

    Please answer...

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

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

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

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

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

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

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

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

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

    Hope this helps,
    Craig B-)

    If someone useful or appropriate, please mark accordingly.

  • REF Cursor with search string

    Hello all,.

    I'm trying to implement a procedure that returns records in the hr.employees table when search strings are passed.

    Here is the package:
    create or replace package search_app 
    IS
    --
    TYPE emp_rec IS RECORD (last_name     hr.employees.last_name%TYPE
                                         ,first_name    hr.employees.first_name%TYPE
                                         ,job_id        hr.employees.first_name%TYPE
                                         ,salary        hr.employees.salary%TYPE
                                         ,dept          hr.departments.department_name%TYPE
                                         );
    --
    TYPE emp_curs  IS REF CURSOR RETURN emp_rec;
    --
    PROCEDURE  get_employees (p_last_name_search   IN  hr.employees.last_name%TYPE
                                             ,p_first_name_search  IN  hr.employees.first_name%TYPE
                                             ,p_job_id_search      IN  hr.employees.job_id%TYPE
                                             ,pr_emps              OUT emp_curs
                                             ,p_error              OUT VARCHAR2
                                             );
    --
    END search_app;
    /
    --
    create or replace package body search_app
    IS
    --
    PROCEDURE get_employees (p_last_name_search    IN  hr.employees.last_name%TYPE
                                            ,p_first_name_search  IN  hr.employees.first_name%TYPE
                                            ,p_job_id_search      IN  hr.employees.job_id%TYPE
                                            ,pr_emps              OUT emp_curs
                                            ,p_error              OUT VARCHAR2
                                            )
    IS
    --
      v_last_name_search       hr.employees.last_name%TYPE;
      v_first_name_search       hr.employees.first_name%TYPE;
      v_job_id_search             VARCHAR2(100);
      v_error_msg                  VARCHAR2(200);
    --
    BEGIN
    --
      OPEN  pr_emps FOR
    --
          SELECT e.last_name
                     ,e.first_name
                     ,e.job_id
                     ,e.salary
                     ,d.department_name as dept
          FROM hr.employees    e
                  ,hr.departments d
          WHERE (e.first_name LIKE p_first_name_search
                       AND
                     --OR   
                      e.last_name  LIKE p_last_name_search
                       AND 
                    --OR  
                       e.job_id     IN   p_job_id_search
                     )
          AND    d.department_id = e.department_id;
    --
        p_error := v_error_msg;
    --
    EXCEPTION
    --
    WHEN OTHERS THEN
       v_error_msg := SUBSTR(SQLERRM,1,200);
    END get_employees;
    --
    END search_app;
    /
    sho error
    
    ---
    here is the stub I am using to test.
    --
    set serveroutput on size 1000000
    spool search_app_OR.log
    --
    DECLARE
    --
      v_first_name_search     hr.employees.first_name%TYPE;
      v_last_name_search      hr.employees.last_name%TYPE;
      v_job_id_search           VARCHAR2(100);
      my_emps                    search_app.emp_curs;
    --
      v_first_name            hr.employees.first_name%TYPE;
      v_last_name             hr.employees.last_name%TYPE;
      v_job_id                  VARCHAR2(100);
      v_salary                   hr.employees.salary%TYPE;
      v_dept_name           hr.departments.department_name%TYPE;
      v_error_msg             VARCHAR2(200);
    --
      v_count                   PLS_INTEGER;
    --
    BEGIN
    --
        v_first_name_search := '%';
        v_last_name_search  := 'De%';
    --        v_job_id_search := '%';
        v_job_id_search     := chr(40)||chr(39)||'AD_VP'||chr(39)||','||chr(39)||'SH_CLERK'||chr(39)||chr(41);
    
    --
         search_app.get_employees(p_last_name_search   => v_last_name_search
                                 ,p_first_name_search  => v_first_name_search
                                 ,p_job_id_search      => v_job_id_search
                                 ,pr_emps              => my_emps
                                 ,p_error              => v_error_msg
                                  );
    --
         LOOP
    --
            FETCH my_emps INTO v_last_name, v_first_name,v_job_id, v_salary, v_dept_name;
                EXIT when my_emps%NOTFOUND;
    --
            DBMS_OUTPUT.PUT_LINE ('...last_name : '||v_last_name);
            DBMS_OUTPUT.PUT_LINE ('...first_name: '||v_first_name);
            DBMS_OUTPUT.PUT_LINE ('...job_id    : '||v_job_id);
            DBMS_OUTPUT.PUT_LINE ('...salary    : '||v_salary);
            DBMS_OUTPUT.PUT_LINE ('...dept      : '||v_dept_name);
            DBMS_OUTPUT.PUT_LINE ('...error_msg : '||v_error_msg);
    --
         END LOOP;
    --
         v_count := my_emps%ROWCOUNT;
    --
         CLOSE my_emps;
    --
            DBMS_OUTPUT.PUT_LINE ('v_last_name_search : '||v_last_name_search);
            DBMS_OUTPUT.PUT_LINE ('v_first_name_search : '||v_first_name_search);
            DBMS_OUTPUT.PUT_LINE ('v_job_id_search       : '||v_job_id_search);
            DBMS_OUTPUT.PUT_LINE ('num rec fetched      : '||v_count);
    --
     EXCEPTION
         WHEN OTHERS THEN
           v_error_msg := SUBSTR(SQLERRM,1,200);
           DBMS_OUTPUT.PUT_LINE ('error: '||v_error_msg);
    END;
    /
    spool off
    The results I get are as follows:

    When I OR in the request for get_employees for search parameters, 106 records are returned.

    When I AND in the application, not of records returned is 0. It should return 2 records. Why is it not return all records? Any suggestion on how this procedure should be applied?

    Thank you

    Raman

    Published by: rxshah on June 8, 2010 12:52 AM

    Hello

    The problem is that you try to implement a dynamic list in a static SQL statement:

    job_id IN '(''AD_VP'',''SH_CLERK'')'
    

    It will not work like that.

    Check out these links for some tips:
    http://tkyte.blogspot.com/2006/06/varying-in-lists.html
    http://asktom.Oracle.com/pls/asktom/f?p=100:11:1242571115131928:P11_QUESTION_ID:110612348061

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

  • PLS-00362: Invalid cursor return type; 'NUMBER' must be a record type

    Hello

    Having a little trouble with the following code example provided to http://www.dba-oracle.com/plsql/t_plsql_cursor_variables.htm:
      1  DECLARE
      2    TYPE t_ref_cursor IS REF CURSOR RETURN NUMBER;
      3    c_cursor  t_ref_cursor;
      4    l_row   NUMBER;
      5  BEGIN
      6    DBMS_OUTPUT.put_line('Strongly typed REF CURSOR using SCALAR type. Expect an error!');
      7    OPEN c_cursor FOR
      8      SELECT COUNT(*) cnt
      9      FROM   cursor_variable_test;
     10    LOOP
     11      FETCH c_cursor
     12      INTO  l_row;
     13      EXIT WHEN c_cursor%NOTFOUND;
     14      DBMS_OUTPUT.put_line(l_row);
     15    END LOOP;
     16    CLOSE c_cursor;
     17* END;
     18  /
      TYPE t_ref_cursor IS REF CURSOR RETURN NUMBER;
                           *
    ERROR at line 2:
    ORA-06550: line 2, column 24:
    PLS-00362: invalid cursor return type; 'NUMBER' must be a record type
    ORA-06550: line 2, column 3:
    PL/SQL: Item ignored
    In the code above, SELECT COUNT (*)... returns a NUMBER. I know it's an aggregation function, but it returns a single value.
    Why can't return a value in a column of a row in a NUMBER?
    How can I change the SQL code so that I can do this?

    Furthermore, I wonder about the use of FETCH with a count (*)... FETCH is supposed to fetch the next row... How it works when you select an aggregate as County?

    Thank you very much
    Jason

    >
    TYPE t_ref_cursor IS REF CURSOR RETURN NUMBER;
    *
    ERROR on line 2:
    ORA-06550: line 2, column 24:
    PLS-00362: Invalid cursor return type; 'NUMBER' must be a record type
    ORA-06550: line 2, column 3:
    PL/SQL: Ignored Element

    In the code above, SELECT COUNT (*)... returns a NUMBER. I know it's an aggregation function, but it returns a single value.
    Why can't return a value in a column of a row in a NUMBER?
    How can I change the SQL code so that I can do this?
    >
    The exception is in line 2: your cursor statement. And the answer is in the text that you access
    >
    The return value of a strongly typed REF CURSOR must be a folder that can be defined using % TYPE % ROWTYPE attributes or record structure.
    >
    You said the CURSOR to return a NUMBER. And as the text says, he must be a 'record '.
    >
    Furthermore, I wonder about the use of FETCH with a count (*)... FETCH is supposed to fetch the next row... How it works when you select an aggregate as County?
    >
    As you said already FETCH retrieves the next line, if any. A query is a request is a request. It returns a result set. A query that uses aggregates returns a result set. A query that does not aggregate returns a result set.

    Your simple COUNT (*) SELECT query returns a result set that consists of a LINE and a line a ONE COLUMN of type NUMBER. Although there is only one column in the result set, what is returned is a RECORD or a LINE. That's why you have to report your data cursor return type a document using the % ROWTYPE or % TYPE attributes or a record structure.

  • The stored procedure PL/SQL - t - it accept the custom Ref Cursor type?

    I am not able to compile the following procedure in the HR schema comes with default oracle... I use Oracle 11g Release 11.2.0.2.0 Express edition. It gives me an error (given after the code block):

    Block of code:
    CREATE OR REPLACE PROCEDURE TEST_REF IS
    DECLARE
    TYPE REF_EMP IS REF CURSOR RETURN % ROWTYPE EMPLOYEES;
    RF_EMP REF_EMP;
    V_EMP EMPLOYEES % ROWTYPE;
    BEGIN
    DBMS_OUTPUT. ENABLE (1000000);
    OPEN FOR RF_EMP
    SELECT * FROM EMPLOYEES WHERE EMPLOYEE_ID > 100;
    EXTRACT THE RF_EMP IN V_EMP;
    DBMS_OUTPUT. PUT_LINE (V_EMP. FIRST_NAME. ' ' || V_EMP. LAST_NAME);
    CLOSE RF_EMP;
    EXCEPTION
    WHILE OTHERS
    THEN DBMS_OUTPUT. PUT_LINE (SQLERRM);
    END TEST_REF;
    /

    Error:
    Errors in PROCEDURE TEST_REF:

    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    2/1 PLS-00103: encountered the symbol "DECLARE" when waiting for an a
    What follows:
    Start function < an ID > pragma procedure subtype type
    < between double quote delimited identifiers > delete the current cursor
    There are the external language prior
    The symbol 'start' is substituted for 'DECLARE' continue.

    16/13 PLS-00103: encountered the symbol "end-of-file" when waiting for him
    one of the following values:
    (begin case declare exit end exception for goto if loop mod)
    pragma raise return null select update while with

    Get rid of the DECLARED:

    SQL> CREATE OR REPLACE PROCEDURE TEST_REF IS
      2  TYPE REF_EMP IS REF CURSOR RETURN HR.EMPLOYEES%ROWTYPE;
      3  RF_EMP REF_EMP;
      4  V_EMP EMPLOYEES%ROWTYPE;
      5  BEGIN
      6  DBMS_OUTPUT.ENABLE(1000000);
      7  OPEN RF_EMP FOR
      8  SELECT * FROM EMPLOYEES WHERE EMPLOYEE_ID > 100;
      9  FETCH RF_EMP INTO V_EMP;
     10  DBMS_OUTPUT.PUT_LINE(V_EMP.FIRST_NAME || ' ' || V_EMP.LAST_NAME);
     11  CLOSE RF_EMP;
     12  EXCEPTION
     13  WHEN OTHERS
     14  THEN DBMS_OUTPUT.PUT_LINE(SQLERRM);
     15  END TEST_REF;
     16  /
    
    Procedure created.
    
    SQL> set serveroutput on
    SQL> exec TEST_REF;
    Donald OConnell
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    SY.

Maybe you are looking for