Create a REF CURSOR as an array of display/temp

Hello world

I had to upgrade a number of Crystal Reports Using REF CURSOR as part of an ERP upgrade project. The new version of the ERP application supports more use of the REF CURSOR and only supports the use of views/tables.

I don't see how I can rewrite the REF CURSOR (which are defined in the PL/SQL procedures), in the form of VIEWS / TEMP TABLES with a single call. That is to say when the user runs the report.

Can anyone suggest a method of conversion of the REF CURSOR in view/Temp Table without the two steps, the steps to populate a temporary table and then, i.e. 1 - 2 - query the table in the report. ??? -I was looking at a Pipelining as an option but again could reach with only two stages, pre filling before running the report.

Any advice would be greatly received.

Kind regards

David.

I found a solution by creating a FUNCTION with a PIPELINED return cursor, and then create a temporary table in the result set. Not really ideal was to use a Pragma AUTONOMOUS_TRANSACTION, but will work for me.

Thank you

David.

Tags: Database

Similar Questions

  • The use of bind variables in dynamic query created for Ref Cursor

    Hello

    I'm in a situation where there is a Ref cursor to which the query is built execution based on a loop. This is why the number of links would be known until the program runs.
    The application is currently using literals instead of bind variables.

    code snippet of the above is
    strSql: = "select * from emp where 1 = 1 and ().

    loop cursor1
    If cond is true then
    strSql = strSql | "ename = ' |" Cursor1.ColumnName;
    end loop;

    Open cursor2 for strSql;

    How to use links in the example above.

    sb92075 wrote:

    user13019948 wrote:
    Hello

    Here is the code I have my trying to change literal-based link to the base.

    What do you mean by "based bind?

    who, what, how determines the values to be 'bound '?

    He's referring to the coding style. He is currently using concatenated literal, and the goal is to change it to use the bindings.

    If I understand this it is known as method 4 dynamic SQL and requires DBMS_SQL. There are examples autour but they vary according to the type of statement being generated - SELECT statements require column lists to be parsed, unlike the INSERT/UPDATE/DELETE.

    This came up recently on my current project and I hit a demo. Here a table of names and values accepted procedure and had to build these in a single WHERE clause along the lines of

    AND t_names(i) = t_values(i)
    

    for an undetermined number of elements in the array. For this demonstration, I used a table that we called "attribute" (don't ask) which has columns including 'attribute_id' and 'name', and I need to build a query along the lines of

    select description from attribute where attribute_id = :b1 and name = :b2
    

    by the way '1012' and 'ISIN' respectively. (I use a table better and after a CREATE statement for her but I have to rush right now, sorry).

    declare
       k_sql_base        constant varchar2(500) := 'select description from attribute';
    
       t_names           constant varchar2_t := varchar2_t('attribute_id',  'name');
       t_values          constant varchar2_t := varchar2_t('1012',          'ISIN');
    
       l_sql             varchar2(500) := k_sql_base;
       l_rows_fetched    integer := 0;
       l_value           varchar2(4000);
    
       l_cursor_handle   integer;
    
    begin
       -- Construct the SQL statement with column names and bind variables e.g.
       -- 'select description from mars.attribute where attribute_id = :b1 and name = :b2'
       for i in t_names.first .. t_names.last loop
          l_sql := l_sql ||
             case i
                when t_names.first then ' where ' else ' and '
             end ||
             t_names(i) || ' = :b' || i;
       end loop;
    
       dbms_output.put_line('SQL statment = ' || l_sql); 
    
       -- Parse the statement we built above (the remaining steps require a parsed cursor):
       l_cursor_handle := dbms_sql.open_cursor;
       dbms_sql.parse(l_cursor_handle, l_sql, dbms_sql.native);
    
       -- Associate the 1st column of output with variable l_value - required for SELECT statements:
       -- (actually the 3rd param here 'column' seems to be only used to get a datatype, in this case we want a string -
       -- dbms_sql.column_value actually extracts the value into a specified variable, which can be different.
       -- All examples in the documentation pass a local variable without further comment, so not entirely clear what this does other than set the output datatype.)
       dbms_sql.define_column(l_cursor_handle, 1, l_value, 4000);
    
       -- Now go through values array binding actual values to :bn variables in the cursor (similar to USING clause of EXECUTE IMMEDIATE)
       for i in t_values.first .. t_values.last loop
          dbms_sql.bind_variable(l_cursor_handle, ':b'||i, t_values(i));
          dbms_output.put_line('Bound :b'||i || ' as ' || t_values(i));
       end loop;
    
       -- Open the cursor and fetch the result (no loop here because we are expecting a single-row result):
       l_rows_fetched := dbms_sql.execute_and_fetch(l_cursor_handle);
    
       -- 'Returns value of the cursor element for a given position in a cursor'
       -- Copy the value of column 1 to variable l_value (has to match
       -- dbms_sql.column_value(l_cursor_handle, 1, l_value);
       dbms_sql.column_value(l_cursor_handle, 1, l_value);
    
       dbms_output.put_line('Result = ''' || l_value || '''');
    
       dbms_sql.close_cursor(l_cursor_handle);
    end;
    

    Hope that helps...

  • How to create a Ref cursor table

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

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


    Thank you.


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

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

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

  • How to create a REF CURSOR from the static values?

    We call for a program of power supply (from PL/SQL) that returns a string with data (separated by {}), lines like this:
    {packetId:236,packetName:ADSL-320K-1M-3G},
    {packetId:257,packetName:ADSL-1024K-1M-20G},
    {packetId:232,packetName:ADSL-INTERANET-UNLIMITED},
    {packetId:234,packetName:ADSL-512K-3M-16G},
    ..................
    .........
    .....
    Our PL/SQL procedure should exit a REF CURSOR with lines like this:
    236,  ADSL-320K-1M-3G
    257,  ADSL-1024K-1M-20G
    232,  ADSL-INTERANET-UNLIMITED
    234,  ADSL-512K-3M-16G
    .........
    ......
    How do this pls?

    Published by: Channa on May 18, 2012 02:30

    Hello

    Channa wrote:
    It's the first gives ORA-00942: table or view does not exist for the FROM t . When I can replace the t split_t , I get ORA-32031: illegal reference to a query with the term name.

    What is at stake here pls?

    Use the name of your real of the table where I used t.
    If you don't have a table, just a string, then select the double.

  • help how to extract the ref cursor in the table field

    Hello.


    I have a query similar to the following:
    select department_id, cursor (select employee_id from employees where department_id = d.department_id)
      from departments d
    Expecting to get several lines, I want this select this option to be in bulk sampled in a table variable nested (of another type of nested table) which is copied to an out parameter in a procedure. I have some doubts:
    1 should. what I create the column in the inner nested table that will keep the result of the ref cursor? Ref cursor colunm? A sort of column Adrien?
    2. If the column in the nested table inside that will keep the result of the ref cursor is another array, how can I write the result of the entire query in a single volume?

    (I want to bulk collect everything in a single query, I know how to do with pl/sql do not inflate but using two nested for loops, that's what I try to avoid).


    Thanks in advance.

    It would be simpler:

    declare
        type dep_emp_list_tbl_type
          is table of sys.OdciVarchar2List;
        v_dep_emp_list_tbl dep_emp_list_tbl_type;
        v_dep_id_tbl sys.OdciNumberList;
    begin
        select  department_id, cast(multiset(select employee_id from hr.employees where department_id = d.department_id) as sys.OdciVarchar2List)
          bulk collect into v_dep_id_tbl,v_dep_emp_list_tbl
          from hr.departments d;
    end;
    /
    

    SY.

  • 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

  • Ref Cursor statement

    TYPE V_TYPE IS REF CURSOR


    V_CUR V_TYPE;


    is that this decalrion is correct or not?

    How do decalre

    user10447332 wrote:
    TYPE V_TYPE IS REF CURSOR

    V_CUR V_TYPE;

    is that this decalrion is correct or not?

    Not. There is no need of a type defined by the user (unless the definition of type strong ref Cursor - use that is questionable in PL/SQL). Use rather SYS_REFCURSOR .

    For example

    --// run in SQL*Plus
    
    --// define a bind variable
    var c refcursor
    
    declare
      myCursor sys_refcursor;
    begin
      --// create the ref cursor
      open myCursor for select * from user_objects order by 1;
    
      --// pass the ref cursor handle to the client
      :c := myCursor;
    end;
    /
    
    --// consume the cursor output in the client
    print c
    
  • REF Cursor creating CSV files

    Hi guys

    I am writing a package to create several different CVS files of the database.
    I created a procedure for each files CVS to be created within the package.
    I set the cursor for each file to each intervention.
    Read slider and concatenate all the fields in a large chain of recording and write it to the file using the UTL_FILE utility.

    Is there a way I can create a common procedure and pass all other cases, file_name as a parameter and concatenate all the fields and records and write it to the file? I think the use of the REF cursor, but the problem is the cursor query is different for each file. Some files has 2 columns and some 200 columns.
    No idea how to make this work for any format?

    Your help will be very appreciated.

    Thanks and greetings

    Vijay

    Here is a generic procedure, I used for my part in the past...

    As user sys:

    CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
    /
    GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
    /
    

    As myuser:

    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
                                         ,p_dir IN VARCHAR2
                                         ,p_header_file IN VARCHAR2
                                         ,p_data_file IN VARCHAR2 := NULL) IS
      v_finaltxt  VARCHAR2(4000);
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_fh        UTL_FILE.FILE_TYPE;
      v_samefile  BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
    BEGIN
      c := DBMS_SQL.OPEN_CURSOR;
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      d := DBMS_SQL.EXECUTE(c);
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
        END CASE;
      END LOOP;
      -- This part outputs the HEADER
      v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
      FOR j in 1..col_cnt
      LOOP
        v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
      END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
      UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      IF NOT v_samefile THEN
        UTL_FILE.FCLOSE(v_fh);
      END IF;
      --
      -- This part outputs the DATA
      IF NOT v_samefile THEN
        v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
      END IF;
      LOOP
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        EXIT WHEN v_ret = 0;
        v_finaltxt := NULL;
        FOR j in 1..col_cnt
        LOOP
          CASE rec_tab(j).col_type
            WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                        v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
            WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                        v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                        v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
          ELSE
            v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
          END CASE;
        END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
        UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      END LOOP;
      UTL_FILE.FCLOSE(v_fh);
      DBMS_SQL.CLOSE_CURSOR(c);
    END;
    

    This allows the header line and the data to write into files separate if necessary.

    for example

    SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
    
    PL/SQL procedure successfully completed.
    

    Output.txt file contains:

    empno,ename,job,mgr,hiredate,sal,comm,deptno
    7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
    7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
    7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
    7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
    7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
    7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
    7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
    7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
    7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
    7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
    7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
    7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
    7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
    7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10
    

    The procedure allows for the header and the data to separate files if necessary. Just by specifying the file name "header" will put the header and the data in a single file.

    Adapt to the exit of styles and different types of data are needed.

  • How to create control provided by PL/SQL ref-cursor

    Dear valuable experts,

    I'm migrating oracle forms10g for JDeveloper. Currently I need a guideline or a reference to create pages of the ADF using the PL/SQL-Refcursor rather then tables or views.

    I need help also how can I create using PL/SQL (package) - Refcursor datacontrol.

    Please help me.

    (!)
    Thank you.
    Zed
    ====

    Zed,

    The Fusion developer's Guide has 35.9.4 article titled "How to create a view object on a REF CURSOR" which should help you.

    John

  • Call a procedure stored via JDBC with a REF CURSOR * input variable.

    Hello

    S/n of my client has provided me with a stored procedure that I need to call to get information about products prices. Something along the lines of:

    some_package.getPrices (products IN OUT csr_type);

    where csr_type represents a REF CURSOR. This cursor has a product ID column and a price column. The plan is to move the cursor with the populated product id column and have the routine decorate the slider with the prices.

    The setting in this plan is that it seems that it is not possible to go from JDBC REF CURSOR in . However, I'm not sure, since I can only find throw comments on various forums (e.g. http://www.orafaq.com/forum/t/35088/0/), without any reference. If I go back to the client and tell them that their idea will not work, I prefer to be able to point them to a documentation somewhere

    So I guess my questions are:

    1. it is indeed impossible to pass a REF CURSOR type as a variable input on JDBC to a stored procedure?

    2. is there information I can do about my client?

    3. am I on the right track thinking I need to go down the path of an array of objects?

    Thank you very much to anyone who can help
    Peter Svehla.

    Hi Peter,.

    I see it, missed that you actually want to pass in a list of products. Don't think that you can do this with the current procedure. A slider is just a pointer to a result set.
    How the result set is created and what it looks like, is determined when the cursor is opened.

    What does this procedure with the cursor? -It does not have some OPEN TO ; inside?

    Or, perhaps, you are supposed to send in an open cursor (does not much sense to me)?

    Concerning
    Peter

  • Ref Cursor remote procedure fails

    Remote database server Oracle 9iR2 1

    Local database server Oracle 10 g 2 2

    Remote procedure:

    CREATE OR REPLACE PROCEDURE p_get_results (   i_query   IN   VARCHAR2
                                                , o_refc    OUT  sys_refcursor
                                              )
    AS
    BEGIN
        IF ( i_query IS NULL )
        THEN
             RAISE_APPLICATION_ERROR(-20001,'The paramter i_query cannot be null') ;
        END IF ;
    
    
        OPEN o_refc FOR i_query ;
        
        EXCEPTION
            WHEN   others   THEN
                 RAISE ;
    END p_get_results ;
    /
    
    

    Local PL/SQL block

    SQL> var i_query varchar2(100)
    SQL> var o_refc refcursor
    SQL> exec :i_query := 'select count(*) from oo_attrs'
    
    
    SQL> exec p_get_results@demo_oo2 (:i_query,:o_refc)
    
    
    ERROR at line 1:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-01001: invalid cursor
    
    

    Check the link works and request db:

    SQL> select count(*) from oo_attrs@demo_oo2;
    
      COUNT(*)
    ----------
           225
    

    Am I missing something here?

    Am I missing something here?

    Yes - you cannot use REF CURSOR over links to db.

  • Ref Cursor

    Hi guys,.

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

    Hi Alex,

    Introduction to the REF CURSOR

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

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

    REFCURSORs have the following characteristics:

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

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

    Kind regards

    Jitendra

  • Report regions - use of the Ref Cursor?

    APEX 4.2

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

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

    Thank you

    HELEN wrote:

    APEX 4.2

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

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

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

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

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

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

  • REF CURSOR as a return of a function in SQL developer

    Hi team,

    I have a function which returns a Ref from a function slider while getting an entry number. But once I have create an implementation of single test on it with a valid entry that he throws error like below and have failed. My SQL developer version is 4.0.2.15.21 and it turns on a Linux OS (GNU/Linux 3.10.0 - 123.6.3.el7.x86_64). Here is the error I get.

    Cannot be converted to NUMBER <oracle.jdbc.driver.OracleResultSetImpl@5925237>.

    oracle.dbtools.raptor.datatypes.oracle.sql.NUMBER.customUnscaledInternalValue(NUMBER.java:93)

    oracle.dbtools.raptor.datatypes.oracle.sql.NumericDatum.customInternalValue(NumericDatum.java:37)

    oracle.dbtools.raptor.datatypes.impl.DataTypeImpl.customInternalValueFilter(DataTypeImpl.java:411)

    oracle.dbtools.raptor.datatypes.impl.DataTypeImpl.getInternalValue(DataTypeImpl.java:399)

    oracle.dbtools.raptor.datatypes.impl.DataValueImpl. < init > (DataValueImpl.java:55)

    oracle.dbtools.raptor.datatypes.impl.DataTypeImpl.customDataValue(DataTypeImpl.java:196)

    oracle.dbtools.raptor.datatypes.impl.DataTypeImpl.getDataValue(DataTypeImpl.java:178)

    Oracle.DBTools.unit_test. Runner.UtRunnerImplIterator$ UtRunnerImplObject.getDynamicValueByName (UtRunnerImplIterator.Java:324)

    Oracle.DBTools.unit_test. Runner.UtRunnerImplIterator$ UtRunnerImplObject.mapDynamicValueByName (UtRunnerImplIterator.Java:301)

    Oracle.DBTools.unit_test. Runner.UtRunnerImplIterator$ UT...

    Please help me out here.

    Please do not post double fillet.

    Mark this thread ANSWER and continue to use your other thread.

    Function taking as input ref cursor but throwing error exit

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

Maybe you are looking for

  • Old iPod will not be displayed in iTunes

    I found my first iPod. Not even sure what year I got it but I'm guessing 12 years ago... It loads when I connect it to the computer and it works like a charm but it will not be displayed in iTunes. iTunes had to have 1 million edits since my last pla

  • How to keep the screen on longer

    The computer stays on a bit of time and I keep after entering the password. Is there a way to keep longer?

  • Check disk at startup of the

    I just started my computer and it is to check the disc and it will last for some time if it takes I can do to escape from all this and just start windows normally? Also how long does take to have this end?

  • Animate the CC crashing on launch...

    on my Macbook Pro, El Capitan 10.11.13. It just closes unexpectedly before the end of the opening. Any ideas?

  • Unable to connect to the high port on Fusion VM 6.0.4

    I have a CentOS 6.5 and 7 VM that are both in Bridge mode.  Can I access the service sshd on the two machines on the network.  I can't access a web service on the network 8090.  I am in a position of "nc 127.0.0.1 8090 ' of the virtual machine itself