Open cursor for PLSQL table of records

Is it possible to open a cursor for all data in a PLSQL table of records?
something like
cursor c (p1 number) is select * from <plsqltab>
where <plsqltab>.col = p1

There is no such thing as a PL/SQL table. Yes, I know that many calls this structure in PL/SQL a table. And that is exactly where all this confusion stems from.. and trying to treat such a "table" as an Oracle table using SQL.
The correct terms are dynamic array (indexed by integer) or dynamic associative array (indexed by varchar). And an array is nothing like a table ito RDBMS processing.
Yes, you can run SQLs against arrays. But it is "expensive". Why? Because the data sits inside PL/SQL Engine. Not in the SQL Engine. The data is in a PL/SQL defined structure. Not a SQL defined structure.
So.. the data needs to be shipped from the PL/SQL Engine to the SQL Engine and converted into a format that the SQL Engine can understand and use.
Also, once shipped and converted the SQL structure is not indexed. Which means that the only option is a full table scan of that structure.
So you need to ask yourself why do you want to use SQL against a PL/SQL array? As soon as you do that, you are saying "Hey, this PL/SQL table ain't good enough and I need to process it using SQL".
So why then does that data sit inside a PL/SQL array and not in a SQL table?
Oracle provides you with the ability to create temporary session tables. These can be indexed. SQL can be run against them without all the "expenses" that are associated with running SQL against a PL/SQL array.
PL/SQL arrays is a great tool. But only when it is the right tool to use. When someone says he/she needs SQL to use this tool, then I question the choice of the tool. Make sure you use the right tool for the job.

Similar Messages

  • Open cursor for plsql table

    There's a way to open a cursor from a plsql table?

    Hello
    Have a look here:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:13876292179522624220::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:666224436920,

  • Open cursor for internal table

    Hi folks,
    I have a tricky question concerning the cursor function and internal tables. First of all, it is not possible to create a view. Instead I've to use a function module for extracting some data to the BI system.
    Actually most of the time I work with SELECT (for outer joins) and internal tables. At the end I have a internal table and must open an cursor. As fact, I can't open a cursor for an internal table - only database tables are allowed.
    OPEN CURSOR WITH HOLD s_cursor FOR SELECT * FROM lt_temp.
    Does someone have a clue how to solve my problem? Obviously I have to use a db table for a open cursor statement but on the same way I have to use a internal table for all my previous SELECT-statements.
    Thanks in advance for your help.
    Regards,
    Mrcl

    Why don't you use EXEC and ENDEXEC
    Check this link
    http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3b8b358411d1829f0000e829fbfe/content.htm

  • Open cursor for ...using...

    Hi all
    1 general question- can someone explain me how 'using keyword in 'open cursor for ...' statement works.
    Does it replace where clause and how?
    open cur_xx for qry_xxx using text_xxx
    where 'text_xxx' is going to be my codition in select statement
    Tahnks everyone

    http://oraclesvca2.oracle.com/docs/cd/B10501_01/appdev.920/a96624/13_elems35.htm

  • Maximum Open cursor  Exceeded error when deleting records from a table

    I have a strange problem.
    I have a table EMP_MASTER . Whenever I am trying to delete a record from this table, I am getting Maximum no. of open cursor exceeded error. But this error doesnot come when i delete from any other tables. And no. of open cursor is much lesser than OPEN_CURSOR parameter.
    All other tables (around 700) has foreign key constraint to this EMP_MASTER table for created_user paramater.
    Is it some thing like, when I am trying to delete a record from EMP_master, implicit cursor opens up and checks all referenced tables. and that limit gets exceeded ?
    Please help.
    Thanks,
    Raj

    Raji03 wrote:
    There is no trigger defined for this table.
    Is there a limit on which no.of references made to a column ? Because one column in this field, Emp no is being referenced in almost every other table. around 700 tables. Will it have any adverse effect ?That should have nothing to do with your problem directly. Again, those tables could have triggers defined on them and you are leaking cursors in one of those triggers (wild guess).
    An example of a table with many many others foreign key'd to it.
    create table parent_of_everything
       column1 number primary key
    insert into parent_of_everything select level from dual connect by level <= 1000;
    commit;
    --create 1000 tables all with foreign keys to the parent_of_everything
    begin
       for i in 1 .. 1000
       loop
          execute immediate 'create table child_' || i || ' (column1 number, column2 number, constraint child_' || i || '_fk foreign key (column1) references parent_of_everything (column1) on delete cascade)';
          execute immediate 'insert into child_' || i || ' select level, mod(level, ' || i || ') from dual connect by level <= 1000';
          commit;
       end loop;
    end;
    TUBBY_TUBBZ?delete parent_of_everything;
    1000 rows deleted.
    Elapsed: 00:02:53.03No problems were had (none were expected).
    Cleanup script.
    --remove the 1000 child tables
    begin
       for i in 1 .. 1000
       loop
          begin
             execute immediate 'drop table child_' || i || ' purge';
          exception when others
             then
                null;
          end;
       end loop;
    end;
    /

  • Open cursor for a nested table

    Hi,
    I want to open a cursor like:
    open c1 for select * from emp;
    BUT
    I what the cursor results to be populated with contents of a nested table or associative array..
    How can this be done???
    Thanks in advance,
    teo

    Well, given a variable YOUR_EMP of nested table type EMP_NT it could be as simple as
    open c1 for select * from TABLE( CAST(your_emp AS emp_nt));Cheers, APC

  • Open cursor for and bind variables

    Hello all,
    how can I assign values to a bind variable before opening a cursor?
    example code:
    DECLARE
       TYPE ref_cur_t IS REF CURSOR;
       l_ref_cur   ref_cur_t;
       l_query VARCHAR2 (100)
             := 'select * from table t1 where ndx= :var_index' ;
    BEGIN
       -- assign a value to :var_index
       OPEN l_ref_cur FOR l_query;
    END;Thanks!

    Something like this ->
    scott@ORCL>
    scott@ORCL>DECLARE
      2     l_ref_cur   sys_refcursor;
      3     l_query VARCHAR2 (100) := 'select * from emp where empno = :var_index';
      4     l_empno  number(4);
      5  BEGIN
      6     l_empno := &emno;
      7     -- assign a value to :var_index
      8     OPEN l_ref_cur FOR l_query using l_empno;
      9  END;
    10  /
    Enter value for emno: 7698
    old   6:    l_empno := &emno;
    new   6:    l_empno := 7698;
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:19.78
    scott@ORCL>Regards.
    Satyaki De.

  • Open Cursor for insert actually inserts

    Have been using code similar to this to prepare an SQL insert
    statement before entering a loop to perform the inserts. Find
    that the open actually performs an insert when it is executed,
    so the table always has an extra row of garbage.
    Is there some way to stop this behaviour? ProC compiler option
    or open parameter. Currently I am doing a ROLLBACK after the
    open to clear it.
    Using the prepare because the table name is not known at compile
    time.
    EXEC SQL AT DB_1 PREPARE insert_cust FROM :szSqlInsertCustomer;
    EXEC SQL AT DB_1 DECLARE insert_cust_cursor CURSOR FOR insert_cust;
    EXEC SQL AT DB_1 OPEN insert_cust_cursor USING :customerId;
    for ( ....)
    customerID = ...;
    EXEC SQL AT DB_DCMS EXECUTE insert_cust;
    Also tried passing in the tablename as a host variable
    EXEC SQL INSERT INTO :szTableName (CUSTOMER_ID) VALUES (:customerId);
    ProC compiler gives the following error:
    INSERT INTO :szTableName (CUSTOMER_ID) VALUES (:customerId);
    ........................1
    PCC-S-02201, Encountered the symbol ":" when expecting one of the following:
    ( an identifier, a quoted string, date, table, count,
    extract, interval, multiset, the, time, timestamp, treat,
    trim, avg, max, min, sum, stddev, variance,
    Thanks

    You don't DECLARE and OPEN an insert statement (just selects). Just use EXECUTE ... USING ...

  • OPEN CURSOR FOR  DELETE ROWS

    This transaction will work properly?
    I know it work but I have feeling it may cause a problem
    To open a cursor and delete the row I have selected.
    CREATE OR REPLACE PROCEDURE PRC_MAIN_INTER IS
    BEGIN
    BEGIN
    FOR A IN (SELECT B.HIST_ID
    FROM MOBIDEO.MAIN_INTER B
    WHERE B.STATUS = 9)
    LOOP
    BEGIN
    DELETE MAIN_INTER C WHERE C.HIST_ID = A.HIST_ID;
    COMMIT;
    END LOOP;
    END;
    COMMIT;
    END PRC_MAIN_INTERF;

    Sagi wrote:
    Toon Koppelaars wrote:
    Why not just:
    BEGIN
    DELETE FROM MOBIDEO.MAIN_INTER B WHERE B.STATUS = 9;
    COMMIT;
    END;
    The original transaction is longer I have truncate it .
    It also use log HIST_ID and some more detail for log table .Question: Are mobideo.main_inter and main_inter the same table? If so then
    declare
      cursor c_main_inter is select hist_id from main_inter where status=9 for update;
    begin
      for c in c_main_inter
      loop
        -- Logging, any other processing, etc.
        delete from main_inter where current of c_main_inter;
      end loop;
      commit;
    end;

  • Open cursor for existing procedure

    Is it possible to open a refcursor for an existing procedure as apposed to opening a refcursor for a standard select statement. For example:
    Standard select:
    OPEN refcursor FOR
    select * from my_table;
    RETURN the_cursor;
    Based on an existing procedure:
    OPEN refcursor FOR
    my_package.my_procedure();
    RETURN the_cursor;
    Note: my_procedure returns a table of record type rows defined by myself in the package spec.
    Any help is much appreciated
    Regards
    Tony

    Hi Sven
    Thank you for that information however I am still a little unsure as to how to call the procedure including the necessary parameters. The procedure in question has the following IN parameters with one OUT parameter.
    my_procedure (p_context_id in number,
    p_username in varchar2,
    p_mdata out mtab)
    As you stated, if it is a procedure, which it is, then use the following:
    my_package.my_procedure(the_cursor);
    However if I need to pass parameters in the call that kind of conflicts where 'the_cursor' is?
    Any ideas?
    Tony

  • Parameterized cursor for varient Table name?

    Hi all,
    I am using Oracle 9i and have a cursor defined as :-
    Code:
    CREATE PROCEDURE Proc_Abc
    AS
    CURSOR
    My_Cursor (UserName VARCHAR) IS
    SELECT Emp_Name, Salary FROM Employee_Table
    WHERE User_Name = UserName;     
    (Rest of the code)
    This code is working perfectly, but if I try to provide the table name through the cursor variable, it gives an error
    Below is the code that I am writing to pass table name through variable:-
    Code:
    CREATE PROCEDURE Proc_Abc
    AS
    CURSOR
    My_Cursor (TableName VARCHAR, UserName VARCHAR) IS
    SELECT Emp_Name, Salary FROM TableName
    WHERE User_Name = UserName;     
    (Rest of the code)
    All the tables that I need to pass through cursor variables have the same fields and are all pre known to me, thats why "SELECT Emp_Name, Salary " is remaining common throughout.
    Please suggest how can I make a cursor with variant tables?
    Thanks in advance.

    The following procedure compares between two tables and then it picking the column from all_tab_column table and finally execute the SELECT statement to compare the data between this two table. But, you can proceed your program taking help from this -
    satyaki>ed
    Wrote file afiedt.buf
      1  create or replace procedure compr_tab_dat(TAR_TAB IN VARCHAR2,
      2                                            TAR_UID IN VARCHAR2,
      3                                            SRC_TAB IN VARCHAR2,
      4                                            SRC_UID IN VARCHAR2)
      5  is
      6   cursor c1
      7   is
      8    select column_name
      9    from (
    10           select column_name,column_id
    11           from all_tab_columns
    12           where table_name = SRC_TAB
    13           and   owner = SRC_UID
    14           intersect
    15           select column_name,column_id
    16           from all_tab_columns
    17           where table_name = TAR_TAB
    18           and   owner = TAR_UID
    19         )
    20     order by column_id;
    21   cursor c_count
    22   is
    23     select count(column_name) as c_cnt
    24     from (
    25             select column_name
    26             from all_tab_columns
    27             where table_name = SRC_TAB
    28             and   owner = SRC_UID
    29             intersect
    30             select column_name
    31             from all_tab_columns
    32             where table_name = TAR_TAB
    33             and   owner = TAR_UID
    34           );
    35   rec1 c1%rowtype;
    36   rec2 c1%rowtype;
    37   rec3 c1%rowtype;
    38   rec6 c_count%rowtype;
    39   cnt  number(10);
    40   cnt1  number(10);
    41   str  varchar2(32000);
    42   --str  clob;
    43  BEGIN
    44     cnt := 0;
    45     cnt1 := 1;
    46     dbms_output.enable(10000000);
    47     for rec6 in c_count
    48     loop
    49      cnt := rec6.c_cnt;
    50     end loop;
    51     if cnt = 0 then
    52        dbms_output.put_line('No matched columns found.... ');
    53     else
    54        dbms_output.put_line('UnMatched Datas Are-- ');
    55           str:='declare '||
    56          '  cursor c3 '||
    57          '  is '||
    58          '    select ';
    59           open c1;
    60           loop
    61             fetch c1 into rec1;
    62             exit when c1%notfound;
    63             if cnt = cnt1 then
    64                str:= str||rec1.column_name;
    65             elsif cnt1<cnt then
    66               str:= str||rec1.column_name||',';
    67             end if;
    68             cnt1 := cnt1 + 1;
    69           end loop;
    70           close c1;
    71           str:=str||' from '||SRC_TAB||
    72                ' minus '||
    73                ' select ';
    74           cnt1:=1;
    75           open c1;
    76           loop
    77             fetch c1 into rec2;
    78             exit when c1%notfound;
    79             if cnt = cnt1 then
    80                str:= str||rec2.column_name;
    81             elsif cnt1<cnt then
    82                str:= str||rec2.column_name||',';
    83             end if;
    84             cnt1 := cnt1 + 1;
    85           end loop;
    86           close c1;
    87           str:=str||' from '||TAR_TAB||';'||
    88                ' r3 c3%rowtype; '||
    89                ' begin '||
    90                '   for r3 in c3 '||
    91                '   loop '||
    92                '     dbms_output.put_line(';
    93           cnt1:=1;
    94           open c1;
    95           loop
    96             fetch c1 into rec3;
    97             exit when c1%notfound;
    98             if cnt = cnt1 then
    99                str:= str||' r3.'||rec3.column_name;
    100             elsif cnt1<cnt then
    101                str:= str||' r3.'||rec3.column_name||
    102                     '||'',''||';
    103                cnt1 := cnt1 + 1;
    104             end if;
    105           end loop;
    106           close c1;
    107           str:=str||');'||
    108                ' end loop;'||
    109                ' exception '||
    110                '   when others then '||
    111                '     dbms_output.put_line(sqlerrm); '||
    112                ' end; ';
    113     end if;
    114     execute immediate(str);
    115     --dbms_output.put_line(str);
    116  exception
    117    when others then
    118      dbms_output.put_line(sqlerrm);
    119* END;
    120  /
    Procedure created.
    satyaki>
    satyaki>
    satyaki>
    satyaki>create table emp_t
      2     as
      3       select * from emp
      4       where rownum < 5;
    Table created.
    satyaki>
    satyaki>
    satyaki>desc emp;
    Name                                      Null?    Type
    EMPNO                                     NOT NULL NUMBER(4)
    ENAME                                              VARCHAR2(10)
    JOB                                                VARCHAR2(9)
    MGR                                                NUMBER(4)
    HIREDATE                                           DATE
    SAL                                                NUMBER(7,2)
    COMM                                               NUMBER(7,2)
    DEPTNO                                             NUMBER(2)
    satyaki>
    satyaki>
    satyaki>desc emp_t;
    Name                                      Null?    Type
    EMPNO                                              NUMBER(4)
    ENAME                                              VARCHAR2(10)
    JOB                                                VARCHAR2(9)
    MGR                                                NUMBER(4)
    HIREDATE                                           DATE
    SAL                                                NUMBER(7,2)
    COMM                                               NUMBER(7,2)
    DEPTNO                                             NUMBER(2)
    satyaki>set lin 1000
    satyaki>
    satyaki>select * from emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    14 rows selected.
    satyaki>
    satyaki>
    satyaki>select * from emp_t;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
    satyaki>
    satyaki>
    satyaki>set serveroutput on
    satyaki>
    satyaki>
    satyaki>begin
      2   compr_tab_dat('EMP_T','SCOTT','EMP','SCOTT');
      3  end;
      4  /
    No matched columns found....
    ORA-06535: statement string in EXECUTE IMMEDIATE is NULL or 0 length
    PL/SQL procedure successfully completed.
    satyaki>
    satyaki>
    satyaki>sho user;
    USER is "TRG2"
    satyaki>
    satyaki>
    satyaki>
    satyaki>
    satyaki>begin
      2       compr_tab_dat('EMP_T','TRG2','EMP','TRG2');
      3     end;
      4      /
      5  .
    satyaki>
    satyaki>ed
    Wrote file afiedt.buf
      1  begin
      2       compr_tab_dat('EMP_T','TRG2','EMP','TRG2');
      3* end;
    satyaki>/
    UnMatched Datas Are--
    7654,MARTIN,SALESMAN,7698,28-SEP-81,1250,1400,30
    7698,BLAKE,MANAGER,7839,01-MAY-81,2850,,30
    7782,CLARK,MANAGER,7839,09-JUN-81,2450,,10
    7788,SCOTT,ANALYST,7566,19-APR-87,3000,,20
    7839,KING,PRESIDENT,,17-NOV-81,5000,,10
    7844,TURNER,SALESMAN,7698,08-SEP-81,1500,0,30
    7876,ADAMS,CLERK,7788,23-MAY-87,1100,,20
    7900,JAMES,CLERK,7698,03-DEC-81,950,,30
    7902,FORD,ANALYST,7566,03-DEC-81,3000,,20
    7934,MILLER,CLERK,7782,23-JAN-82,1300,,10
    PL/SQL procedure successfully completed.N.B.: May be Any other member can come with much shorter or better technique than this one. But, according to your requirement - i'm posting it. Hope this will help you, or atleast give you some idea.
    Regards.
    Satyaki De.

  • Open cursor for a dynamic query

    Hi,
    I'm using forms6i and db 10g
    I want to create a procedure like below
         PROCEDURE pop_cursor (generic_cur IN OUT gencurtyp, querystring varchar2) IS
         BEGIN
              OPEN generic_cur FOR querystring;
         END;where generic_cur is a Ref Cursor and querystring will contain a query statement like 'select col1... from table1'
    The above way i'm not able to do that, i'm getting error
    Encountered the symbol 'QUERYSTRING' when expecting on of the following:
    select
    Is there any alternative??
    Please help

    You can only use that sort of dynamic sql in the database. maybe you can return the ref cursor to the form from a db-function, i don't know if it works in forms 6i.
    But you could tell us your requirement, maybe you can implement it without these dynamic things.

  • Open cursor for string and select from partition (cannot bind)

    Hi,
    i don't manage to use a bind variable for a select ... from ... PARTITION(...).
    It doesn't work to use something like
    open cur for 'select ... from ... PARTITION(:1) where ...' using 'NDAY_20120301';So i have to create the cursor string with string functions each time i change the partition.
    But that means, that the string changes each time.
    Doesn't that prevent from re-use in library_cache?
    best regards,
    Frank

    >
    So i have to create the cursor string with string functions each time i change the partition.
    But that means, that the string changes each time.
    >
    Yes it does.
    Doesn't that prevent from re-use in library_cache?
    >
    Yes it does.
    So why do you care? Unless you have large numbers of partitions what difference does it make? Bind variables are useful to keep Oracle from doing hard parses of queries that are basically the same but use different filter values. Such as an INSERT statement that uses different values FOR EACH ROW rather
    You are just constructing the main (non-filter) part of the query one time and need a single value for the entire query regardless of how many rows - that isn't really a use case for bind variables and isn't going to provide any real benefit.
    So the real question is why do you even care about something that wouldn't provide any benefit to you even if you could do it?
    Looks like you just want to 'roll your own' parallel processing rather that use, and pay for, Oracle's parallel functionality.
    If each partition uses its own tablespace you could filter on the FILE Id of the ROWIDs since the file number will be different for each tablespace and datafile.
    1. Determine the list of file numbers for each partitions tablespace.
    2. Use a WHERE DBMS_ROWID.ROWID_RELATIVE_FNO (ROWID) = :n filter (or use IN (:n1, :n2))to filter rows based on file number(s) for the partition you want
    See DBMS_ROWID.ROWID_RELATIVE_FNO in the PL/SQL Packages and Types doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_rowid.htm#i1004259

  • OPEN cursor for large query

    OPEN cursor
    When you OPEN a cursor for a mult-row query, is there a straightforward way that you can have it only retrieve a limited number of rows at a time and then automatically delete those rows as you do the FETCH against them? I'm thinking of setting up multiple sequential cursors, and opening and closing them as the rows are processed. But I'm hoping there might be a better way.
    The problem is that I'm running out of TEMPORARY during the OPEN cursor stage.
    The application I am working on needs to work in Standard Edition and Personal Edition versions of Oracle.
    Thank you.

    Thanks - I had read the documentation before, but interpreted it differently.
    What I had read was in:
    http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14261/sqloperations.htm#i45288
    The extract of interest was:
    Opening a Cursor
    Opening the cursor executes the query and identifies the result set, which consists of all rows that meet the query search criteria. For cursors declared using the FOR UPDATE clause, the OPEN statement also locks those rows. An example of the OPEN statement follows:
    DECLARE
    CURSOR c1 IS SELECT employee_id, last_name, job_id, salary FROM employees
    WHERE salary > 2000;
    BEGIN
    OPEN C1;
    Rows in the result set are retrieved by the FETCH statement, not when the OPEN statement is executed.
    My interpretation was that the result of the query was put into the temporary tablespace and then retrieved into the program during the FETCH.
    Assuming I was wrong, what I'm wondering now is how I can possibly be running out of temporary space during this OPEN cursor process.

  • Open cursor for dynamic sql

    Hi
    I am using oracle 8.1.7 on solaris.
    I have created
    SQL> CREATE OR REPLACE PACKAGE TEST_PKG AS
    2 TYPE row_cursor IS REF CURSOR RETURN TEMP_TAB%ROWTYPE;
    3 PROCEDURE Return_Columns_proc (c_return IN OUT row_cursor);
    4 END TEST_PKG;
    5 /
    Package created.
    now i am trying to create the procedure Return_Columns_proc by
    CREATE OR REPLACE PACKAGE BODY TEST_PKG AS
    PROCEDURE Return_Columns_proc (c_return IN OUT row_cursor) AS
    QUERY_STR VARCHAR2(850);
    x number ;
    BEGIN
    x:=1;
    QUERY_STR :='SELECT * FROM temp_tab where order_line_id = '||x;
    OPEN c_return FOR QUERY_STR;
    END Return_Columns_proc;
    END TEST_PKG;
    I am getting following error.
    SQL> show error
    Errors for PACKAGE BODY TEST_PKG:
    LINE/COL ERROR
    8/4 PL/SQL: Statement ignored
    8/9 PLS-00455: cursor 'C_RETURN' cannot be used in dynamic SQL OPEN
    statement
    any help for this error.

    The error says it all. You have defined a strong ref cursor and it cannot be used with dynamic sql. However, that does not mean you cannot use the query directly in the OPEN clause
    OPEN c_Return FOR SELECT * FROM temp_tab where order_line_id = X ;

Maybe you are looking for

  • Material group is not updated in EINA

    Hi Experts, We are having a situation for EINA table. Whenever a PIR is created with reference to material, its material group is copied from table MARA to PIR, but it is not being updated in EINA table. Where as if PIR is created with refernce to ma

  • SDO_TOPO_MAP.GET_EDGE_ADDITIONS

    Before any topo manipulation I have... SQL> select count(*), max(edge_id) from mgf_test_edge$; COUNT(*) MAX(EDGE_ID) 19844 19844 I create and load a topo_map... SQL> EXECUTE sdo_topo_map.create_topo_map('MGF_TEST', 'my_topo_map_cache'); PL/SQL proced

  • Alignment Problem in Production server

    Hi friends,      I am developing one report in which all the amount fields are right aligned and works fine in dev server, but the same report exeuting in  in Production server some of  the amout fields are left-aligned. I am using the same Varient i

  • Copernicus Repository View, Search or Filter feature?

    Hi, is there a possibility, to search for a BO or a Data Type within 'Copernicus Repository View'? This would make my day way easier. Not searching all the time for BOs, which package and so on? If not, could SAP develop something like that? Really c

  • OS X (10.5.2) constantly changing set default programs

    After upgrading to Leopard from Tiger I am encountering the following problem: OS X is constantly changing my set default programs to whatever is the default when you install it fresh. For example: I have Firefox set as default for webbrowsing, Adium