REF cursor kicking package compilation error

I have a package with the following procedure:
PROCEDURE INTERPRET_DATAVRSN (
     p_table      IN VARCHAR2)

AS
   cursor Generic_Tab IS REF CURSOR;

   c_sub Generic_Tab;
   v_SQL VARCHAR2(2000);
   v_SQLUpdate VARCHAR2(2000);
   v_RawDataVrsn VARCHAR2(200);

BEGIN
   -- Start by selecting all of the unique values in the table.
   v_SQL := 'select distinct DataVrsn_in from '||p_table||' ';

   OPEN c_sub for v_SQL;
   -- Then process each unique value.
   Loop
      FETCH c_sub into v_RawDataVrsn;
      exit when c_sub %notfound;

        v_SQL := 'update '||p_table||' set DataVrsn=''';
      if (Instr(Upper(trim(v_RawDataVrsn)), 'V') > 0) then
         begin
            v_SQL := v_SQL||Replace(v_RawDataVrsn, 'V', '')||''' ';
         end
      else
         begin
             v_SQL := v_SQL||v_RawDataVrsn||''' ';
         end
      end if;

    v_SQL := v_SQL||''' where DataVrsn_in='''||v_RawDataVrsn||''' ';

        EXECUTE IMMEDIATE v_SQL;
   end loop;
   close c_sub;
   commit work;

     EXCEPTION
          WHEN OTHERS THEN
           /*DBMS_OUTPUT.PUT_LINE(' Received CODE=' || SQLCODE || '  MESSAGE=' || SQLERRM);*/
         RAISE;

END INTERPRET_DATAVRSN;
It keeps giving me the error "encountered the symbol"REF"during awaits one of the following values:" any idea of another way to do this dynamic SQL cursor, or is there something I'm not here?

Thank you!

Hello

It should be

type Generic_Tab IS REF CURSOR;
 

and is not

cursor Generic_Tab IS REF CURSOR;

In addition, your if condition does not have a begin and end, you can change it to

      if (Instr(Upper(trim(v_RawDataVrsn)), 'V') > 0) then

            v_SQL := v_SQL||Replace(v_RawDataVrsn, 'V', '')||''' ';

      else

             v_SQL := v_SQL||v_RawDataVrsn||''' ';

      end if;

Arun-

Tags: Database

Similar Questions

  • Package compilation error

    Version of database

    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production

    PL/SQL Release 11.2.0.2.0 - Production

    "CORE 11.2.0.2.0 Production."

    AMT for 32-bit Windows: Version 11.2.0.2.0 - Production

    NLSRTL Version 11.2.0.2.0 - Production

    Hi gurus

    I like to read Oracle PL/SQL Programming, 6th edition - O'Reilly Media by Steven Feuerstein and there, I can see the following code:

    Package specifications

    CREATE OR REPLACE

    PACKAGE restaurant_pkg

    IS

    TYPE item_list_t

    IS

    TABLE OF THE VARCHAR2 (30);

    PROCEDURE eat_that)

    items_in IN item_list_t,

    IN BOOLEAN make_it_spicy);

    END;

    /

    Package body

    CREATE OR REPLACE

    Restaurant_pkg body PACKAGE

    IS

    PROCEDURE eat_that)

    items_in IN item_list_t,

    IN BOOLEAN make_it_spicy_in_in)

    IS

    BEGIN

    FOR indx IN 1... items_in. COUNTY

    LOOP

    Dbms_output.put_line

    (

    CASE

    WHEN make_it_spicy_in_in THEN

    "Spicy."

    END | items_in (indx));

    END LOOP;

    END;

    END restaurant_pkg;

    -------------

    but the problem is I get the error at compile time, please advice:

    Error

    Error (5.13): PLS-00323: subprogram or cursor "EAT_THAT" is declared in a package specification and must be defined in the package body

    Thanks in advance

    Concerning

    Shu

    The second parameter in the package body is make_it_spicy_in_in, while in the specifications, it is called make_it_spicy

  • Problem with weakly typed ref Cursor

    I have problem with a procedure in a package that returns a weakly typed reference cursor.
    The cursor that is returned to give the desired result when connected as sys and sysdba.
    But the user has rights of execution on the slider isn't a result.
    If I run the query for the cursor as a user I get the desired result
    I tried creating a new procedure outside of the package and it still doesn't work the way I want it.

    I tested changing authentication none in sqlnet.ora and still no results

    Procedure
    create or replace procedure ReportUnits (in the SYS_REFCURSOR cResult)
    AS
    Start

    Open the cResult for
    Select distinct c.company, c.name, c.companycode
    all_views o, fakta.balance_table b, fakta.company c
    where b.company = c.company
    and o.view_name like upper(b.company ||) '_' || b.balance_table | '_view %');

    end ReportUnits;
    Tried the two SYS_REFCURSOR and
    Typedef t_cursor as ref cursor;

    I get no error message.

    802379 wrote:
    Sorry user_views does not solve the problem using all user_views I get no result points of view because interested does not belong to the user.

    So who owns the upper(b.company ||) '_' || b.balance_table | views of '_view' %)? And the package is created with copyrighted (by default) or with authid current_user? If the package is created with copyrighted, it still operates as package regardles of owner who runs it. Package owner (not the appellant) must have accsess to view granted directly, without going through role (rights define stored objects do honor no roles). And since rights define package runs as the owner of package, all_views will show views package owner has access, not package calling.

    One last thing - what happens if more than one schema has upper(b.company ||) '_' || b.balance_table | views of '_view' %)? Do you want them or only in a specific schema?

    SY.

  • get a compilation error. I don't know why.

    I get error compilation than for NRMS_INTERFACE BODY of PACKAGE Compilation errors. PKGNDW

    Error: PLS-00113: identifier 'BOOLISDATAAVAILABLE' of the END must match 'PKGND' at line 1, column 29
    Line: 3309
    Text: end boolIsDataAvailable;


    function boolIsDataAvailable (o_errorcode ON the NUMBER,
    o_errortext OUT VARCHAR2) return a Boolean value is
    DataAccess number;
    Boolean boolResult;
    Start
    Start

    Select DATA_ACCESS
    in the DataAccess
    of INTERFACEPARAMETER
    where NUMBER_VALUE = 0;

    boolResult: = true;

    exception

    WHILE OTHERS THEN
    -Encoder assumes that all exceptions here will lead to data is only not available.
    boolResult: = false;




    end;
    return boolResult;
    end;

    end boolIsNDWAvailable;

    Hello
    You have an extra end at the end of your code.
    and to put an end to the square END boolIsNDWAvailable;

    Salim cordially.

    /* Formatted on 2009/09/08 15:11 (Formatter Plus v4.8.8) */
    FUNCTION boolisdataavailable (o_errorcode OUT NUMBER, o_errortext OUT VARCHAR2)
       RETURN BOOLEAN
    IS
       dataaccess   NUMBER;
       boolresult   BOOLEAN;
    BEGIN
       BEGIN
          SELECT data_access
            INTO dataaccess
            FROM interfaceparameter
           WHERE number_value = 0;
    
          boolresult := TRUE;
       EXCEPTION
          WHEN OTHERS
          THEN
    -- coder assumes that any exceptions here will lead to data not being available.
             boolresult := FALSE;
       END;
    
       RETURN boolresult;
    END ;
    

    Published by: Salim champion 2009-09-08 12:12

    Published by: Salim champion 2009-09-08 12:14

  • Reg. Converting a package in a Ref cursor level slider

    Hi guru,.

    I need to convert a package-level slider which contains the clause 'FOR UPDATE OF' in a Ref cursor when the query will be dynamically built with the necessary table name and other settings.

    Using this slider many Update statement were made with the 'WHERE CURRENT OF' included in this clause.

    Now, I've changed my Ref cursor cursor, but when I compile the cursor is dynamic based is not identified, because I get the error message.

    Can someone tell me how to implement?

    I need only go to dynamic bulding of the whole procedure.

    Kind regards
    Vijayasekaran.N

    Maybe you can use around the ROWID. Like this

    Say what your actual code.

    declare
         cursor c
         is
         select *
           from t
            for update of name;
    
         lno t.no%type;
         lname t.name%type;
    begin
         open c;
         loop
              fetch c into lno, lname;
              exit when c%notfound;
    
              update t set name = lno||lname
               where current of c;
         end loop;
         close c;
    end;
    /
    

    With refcursor you can do.

    declare
         type rc is ref cursor;
         c rc;
         lno t.no%type;
         lname t.name%type;
         lrowid rowid;
    begin
         open c for 'select rowid rid, t.*
                   from t
                    for update of name';
         loop
              fetch c into lrowid,lno, lname;
              exit when c%notfound;
    
              update t set name = lno||lname
               where rowid = lrowid;
         end loop;
         close c;
    end;
    /
    

    Published by: Karthick_Arp on December 26, 2008 02:00

  • REF CURSOR ERROR

    I get the following error when you try to select using a ref cursor

    SQL error: ORA-06504: PL/SQL: return variables of the game results or the query types do not match

    Here are the steps that I have followeed. Can someone tell me what I did wrong.

    -CREATE AN OBJECT

    create or replace type rsn_rec as object
      (
     rsn_cd   varchar2(10),
     rsn_desc  varchar2(30)
    );
    

    -CREATES A TABLE OF OBJECT

    create or replace type rsn_tbl as table of rsn_rec;
    

    PACKAGE/CREATED FUNCTION

    create or replace package pkg_rept_test as
      type refcur is ref cursor;
      function get_rsn return rsn_tbl pipelined;
    end pkg_rept_test;
    create or replace package body pkg_rept_test as
      function get_rsn
        return rsn_tbl pipelined is
          o_cursor refcur;
          rec rsn%ROWTYPE;
        begin
          open o_cursor for 
           select 
            rsn_cd,         
            rsn_desc       
           from rsn;
          loop
            fetch o_cursor into rec;
            exit when (o_cursor%notfound);
            pipe row(rsn_rec(rec.rsn_cd,                                                                                                   rec.rsn_desc)
                             );
          end loop;
          return;
      end;
    end pkg_rept_test;
    

    -THE TABLE SELECTION

    select * from table(pkg_rept_test.get_rsn)
    

    -ERROR
    SQL error: ORA-06504: PL/SQL: return variables of the game results or the query types do not match

    Your code works for me just as you posted.

    Connected to:

    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production

    With partitioning, OLAP, Data Mining and Real Application Testing options

    SQL > create table rsn (rsn_cd varchar2 (10), rsn_desc varchar2 (30));

    Table created.

    SQL > insert into rsn values ("cd test", "test description");

    1 line of creation.

    SQL > commit;

    Validation complete.

    SQL > create or replace the rsn_rec as an object type

    2        (

    3 rsn_cd varchar2 (10),

    rsn_desc 4 varchar2 (30)

    5      );

    6.

    Type of creation.

    SQL > create or replace type rsn_tbl in the rsn_rec table;

    2.

    Type of creation.

    SQL > create or replace package pkg_rept_test as

    2 type refcur is ref cursor;

    3 function get_rsn return rsn_tbl in pipeline;

    4 end pkg_rept_test;

    5.

    Package created.

    SQL > create or replace package body pkg_rept_test as

    2 function get_rsn

    3 return rsn_tbl pipeline is

    4 o_cursor refcur.

    5 rec rsn % ROWTYPE;

    6 start

    7. open o_cursor for

    8. Select

    rsn_cd 9,.

    10 rsn_desc

    11 of rsn;

    12 loop

    13 extract o_cursor in rec;

    When exit 14 (o_cursor % notfound);

    line 15 pipe (rsn_rec (rec.rsn_cd, rec.rsn_desc)

    16                               );

    17 end of loop;

    18 return;

    end 19;

    20 end pkg_rept_test;

    21.

    Package body created.

    SQL > select * from table (pkg_rept_test.get_rsn);

    RSN_CD RSN_DESC

    ---------- ------------------------------

    tests of cd test description

  • Packages and poorly Ref Cursor

    SQL Server Developer, I fight with Oracle to say the least. I fought with the poor performance of the extraction of data from the database, but also a multitude of other things. The last number I have is a stored procedure in a package that does not work when run from my .NET code. I have many other packages and stored procedures that are working, but this one is a failure. I don't get any errors, just no data when I should be.

    I would run the toad package and see if it is the stored Proc and packaging, or if there is a problem in my .NET code. My stored procedure accepts a single PARAMETER of type integer, and has two parameters SYS_RefCursor OUT. My SQL uses the parameter (ID field) to select from a table. If I run the select SQL by itself with the hardcoded value ID, it works fine. I can run too where it uses the SQL for open cursors and inserts the data but I can't determine if it worked.

    So, my questions are the following:

    Can I select a Ref_Cursor? I'm trying to do something like that.
    results_cursor SYS_REFCURSOR;
    
    OPEN results_cursor FOR
       SELECT * FROM Person;
    
    SELECT * FROM results_cursor;
    If I could get the 1st issue a response, I can keep up with my next question.

    Thanks in advance.
    Jeff

    Hello

    I don't see an issue of .NET at this point, so you can have the best chance to post in the forum PLSQL, as it seems that if you need help writing a procedure, rather than interacting with a procedure well known in .NET:
    SQL and PL/SQL

    I'm not clear on your question though. Yes, you can read from a slider ref, and you do it by getting him.

    SQL > set serveroutput on

    SQL > declare
    Ref1 2 sys_refcursor;
    3 rec1 emp % rowtype;
    Number 4 NTC;
    5. start
    6. open ref1 for select * from emp;
    7 LOOP
    8 FETCH INTO rec1 ref1;
    9 OUTPUT WHEN ref1% NOTFOUND;
    10 DBMS_OUTPUT. Put_line (' name = ' | rec1.ename);
    11 END OF LOOP;
    12 end;
    13.
    Name = SMITH
    Name = ALLEN
    Name = WARD
    Name = JONES
    Name = MARTIN
    Name = BLAKE
    Name = CLARK
    Name = SCOTT
    Name = KING
    Name = TURNER
    Name = ADAMS
    Name = JAMES
    Name = FORD
    Name = MILLER

    PL/SQL procedure successfully completed.

    SQL >

    Maybe if clarify what you are trying to do or accomplish in "selecting from a ref cursor" it would be useful.

    Greg

  • Ref cursor error message

    Hello expert;

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

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

    .. Please see below.

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

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

    user13328581 wrote:

    Hello expert;

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

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

    .. Please see below.

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

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

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

    RETURN MY_L_CUR;

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

  • DBMS_REDEFINITION package leads to a PLS00201 compilation error

    I try to put a logic of redefining online within a packet but direct issues, in particular the package doesn't seem to know DBMS_REDEFINITION. I can run DBMS_REDEFINITION, only not go in a package or a program named.

    Here is a minimal example that fails:

    -- Executed by the same user
    -- This works just fine:
    BEGIN
      DBMS_OUTPUT.PUT_LINE(SYS.DBMS_REDEFINITION.CONS_USE_ROWID);
    END;
    
    
    -- This generates PLS-00201 error on SYS.DBMS_REDEFINITION:
    CREATE OR REPLACE PACKAGE testpkg
      AUTHID CURRENT_USER
    AS
      gc_int PLS_INTEGER := SYS.DBMS_REDEFINITION.CONS_USE_ROWID;
    END testpkg;
    
    
    -- This does not work because testpkg is invalid:
    BEGIN
      DBMS_OUTPUT.PUT_LINE(testpkg.gc_int);
    END;
    

    The problem is that I can run these instructions to the same user within the same session and I still get the error PLS. I even ran on my own system of sandbox (12 c VM) where I have system privileges, but it does not work. I fiddled with the AUTHID clause but that did not help.

    Related discussions:

    Any suggestions?

    How grant you permission to this user to use dbms_redefinition? It must be a direct subsidy without a role:

    Connected to:
    Oracle Database 11g Release 11.2.0.4.0 - 64bit Production                      
    
    SQL> CREATE OR REPLACE PACKAGE testpkg
      2    AUTHID CURRENT_USER
      3  AS
      4    gc_int PLS_INTEGER := SYS.DBMS_REDEFINITION.CONS_USE_ROWID;
      5  END testpkg;
      6  /                                                                         
    
    Warning: Package created with compilation errors.                              
    
    SQL> drop package testpkg;                                                     
    
    Package dropped.                                                               
    
    SQL> conn / as sysdba
    Connected.                                                                     
    
    SQL> grant all on dbms_redefinition to hr;                                     
    
    Grant succeeded.                                                               
    
    SQL> conn hr/hr
    Connected.
    SQL> CREATE OR REPLACE PACKAGE testpkg
      2    AUTHID CURRENT_USER
      3  AS
      4    gc_int PLS_INTEGER := SYS.DBMS_REDEFINITION.CONS_USE_ROWID;
      5  END testpkg;
      6  /                                                                         
    
    Package created.
    
  • How to clear the Ref Cursor runtime error

    Hello everyone,
    the code as follows
    create or replace 
    procedure Country_sel(key in varchar2)
    as
    cc Res_RelcountryLan.countrycode%type;
    len Res_Language.langname_en%type;
    lid Res_Language.langid%type;
    ab Res_Language.Abrivation%type;
    type refcursorr is ref cursor;
    cur refcursorr;
    d_stmt varchar2(100);
    begin
    d_stmt := 'select RCL.countrycode,RL.langid,RL.langname_'||key||',
    RL.Abrivation from  Res_RelCountryLan RCL inner join Res_Language RL ON RCL.LangId = RL.LangId';
    open cur for d_stmt;
    loop
    fetch cur into cc,lid,len,ab;
    if cur%found then
    dbms_output.put_line(cc||lid||len||ab);
    else
    exit;
    end if;
    end loop;
    close cur;
    commit;
    end  Country_sel;
    When I run this code im getting
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06512: at "RASOOL.COUNTRY_SEL", line 11
    ORA-06512: at line 6
    can you please help me get rid of this problem.


    thanking you,
    Prakash
    
    d_stmt varchar2(100); 
    

    Increase the size of d_stmt. Your an a larger string assignment

    
    d_stmt := 'select RCL.countrycode,RL.langid,RL.langname_'||key||',RL.Abrivation from  Res_RelCountryLan RCL inner join Res_Language RL ON RCL.LangId = RL.LangId'; 
    

    The size of the string above is more than 100 characters.

  • Can I use the packages with compilation errors

    Hello

    I try to use procedures in a package that includes compilation errors. I wonder whether the remaining procedures within this package is usable or not?

    Or is there a way to only compile the correct procedure within this package?

    Thank you very much

    Murat

    user13795669 wrote:
    Not even Possible, I use execute commands as below

    run immediately "@/ var/mcp/loadUtlPkg.sql';" or with another way?

    No, you can not use as you wrote.
    @ - is a special, synonymous with start , sign command SQL * more.
    You cannot use it with the PL/SQL constructor.

    The only way that you can use the body to package not valid with valid package spec - compile another package, dependent on the subject. Not running - compile.

  • 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;
    
  • Ref Cursor help

    Hello


    FOR REC V_LIST LOOPING
    INSERT INTO G_ID_TEMP_COMMON (TC_TYPE, TC_NUMBER_1_COL) VALUES ('T_ID_REPORT_PARM_VALUES', REC KEY);
    END LOOP;


    The above statement a part of the package.

    V_LIST is ref cursor,

    It returns a list of values,

    If place the statement above in the package, it shows error when compiling the package.

    Error:


    Error (17887,2): PL/SQL: statement ignored
    Error (17887,13): PLS-00221: 'V_LIST' is not a procedure or is not defined



    Kind regards
    Fame

    Try this:

    DECLARE
       l_key NUMBER;
    BEGIN
    ...
    LOOP
       FETCH v_list INTO l_key;
       --
       INSERT INTO G_ID_TEMP_COMMON(TC_TYPE,TC_NUMBER_1_COL) VALUES('T_ID_REPORT_PARM_VALUES', l_key);
       --
       EXIT WHEN v_list%NOTFOUND;
    END LOOP;
    ...
    
  • Statement of the type of cursor in package/sp

    Hello
    I use the package with sp than using slider as below:

    --#1============================ PACKAGE
    {THE PACKAGE AS ORA_PK_TR2
    Type CURS_01 IS REF CURSOR;  -return RYBB. T_COLLECT % rowtype;
    Procedure ORA_SP_CUST (present in date_exp,
    END

    --#2============================  BODY
    create or replace
    PACKAGE ORA_PK_TR2 BODY as
    Procedure ORA_SP_CUST (present in date_exp,
    open_CURS_01 OUT CURS_01) IS
    BEGIN
    SQL_string = "(select * de RYBB.)" T_COLLECT where col =' | DATE_EXP)"

    Open_CURS_01 OPEN FOR SQL_STRING;

    END;

    -3 # = RUN_PORTION

    DECLARE
    DATE_EXP DATE;
    OPEN_CURS_01 RYBB. ORA_PK_TR2. CURS_01;
    TYPE_IN RYBB. T_COLLECT % ROWTYPE;       -/ * < = go to the package
    BEGIN
    Date_exp: = 10-seven.-10';
    RYBB. ORA_PK_TR2. () ORA_SP_CUST
    Date_exp = > date_exp.
    OPEN_CURS_01 = > OPEN_CURS_01
    );
    LOOP
    Look FOR open_CURS_01 IN TYPE_IN;
    EXIT WHEN open_CURS_01% NOTFOUND;
    DBMS_OUTPUT. PUT_LINE (TYPE_IN. COL1 | » '|| TYPE_IN. COL2);    -/ sample
    END LOOP;
    END ;}

    I need to put TYPE_IN declation of cursor inside the packaging, so the user who will run this pack/sp deals with this structure. How I can do this,
    I tried to use < return RYBB. T_COLLECT % rowtype; > in the package but then I get:
    Error (122,6): PLS-00455: cursor 'open_CURS_01' cannot be used in a dynamic OPEN SQL statement.
    Not sure I can somehow in the BODY and make it available to the user?

    Help you enjoy.

    Best
    Trent

    Published by: trento on 13 Sep, 2010 14:36

    Hello

    Slider strong Ref (with a return type) cannot be used with dynamic SQL
    because the compiler cannot check dynamic SQL return type during compilation.
    String ref cursor can be used only with static SQL.
    Dynamic SQL can be used only with the low (untyped) cursor variables.

    You can use static SQL in your procedure, look at this example:

    create or replace
    PACKAGE TEST AS
      TYPE CURS_01 IS REF CURSOR RETURN SCOTT.EMP%ROWTYPE;
      Procedure ORA_SP_CUST (EXP_DATE IN date, open_CURS_01 IN OUT CURS_01 );
    END TEST;
    /
    
    CREATE OR REPLACE
    PACKAGE BODY TEST AS
    
      PROCEDURE ORA_SP_CUST (EXP_DATE IN DATE, OPEN_CURS_01 IN OUT CURS_01 ) AS
      BEGIN
        OPEN OPEN_CURS_01 FOR
            SELECT * FROM SCOTT.EMP WHERE SCOTT.EMP.HIREDATE = EXP_DATE;
      END ORA_SP_CUST;
    
    END TEST;
    /
    
    VARIABLE CR REFCURSOR;
    
    BEGIN
       test.ORA_SP_CUST (TO_DATE('1981/12/03', 'yyyy/mm/dd'),
                         :cr );
    END;
    /
    
    print :cr
    
    CR
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------
    EMPNO                  ENAME      JOB       MGR                    HIREDATE                  SAL                    COMM                   DEPTNO
    ---------------------- ---------- --------- ---------------------- ------------------------- ---------------------- ---------------------- ----------------------
    7900                   JAMES      CLERK     7698                   1981/12/03                950                                           30
    7902                   FORD       ANALYST   7566                   1981/12/03                3000                                          20                     
    

Maybe you are looking for