Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2008
    Posts
    17

    Unanswered: Invalid tablename error for weak ref cursor

    I am trying to run the following and run time error occurs saying invalid tablename whereas table exists:-
    create or replace procedure test_ref_cursor is
    TYPE empcurtyp IS REF CURSOR emp_cv empcurtyp;
    emp_rec employees%ROWTYPE;
    tablename1 varchar2(30);
    p_query_string VARCHAR2(100);

    BEGIN
    tablename1:='employees';
    p_query_string := 'SELECT * FROM ' || ':t';
    OPEN emp_cv FOR p_query_string USING trim(tablename1);

    /*OPEN emp_cv FOR -- open cursor variable
    'SELECT * FROM :t' USING trim(tablename);*/
    -- OPEN emp_cv FOR SELECT * FROM || var1;
    LOOP
    FETCH emp_cv INTO emp_rec; -- fetch from cursor variable
    EXIT WHEN emp_cv%NOTFOUND; -- exit when last row is fetched
    -- process data record
    DBMS_OUTPUT.PUT_LINE('Acc = ' || emp_rec.account_id || ' ' ||
    emp_rec.invoice_seq_no );
    END LOOP;
    CLOSE emp_cv;
    END;

    Can anyone help me out?

  2. #2
    Join Date
    Mar 2007
    Posts
    623
    As answered in http://asktom.oracle.com/pls/asktom/...D:227413938857: you cannot bind identifiers, you have to hardcode them into dynamic string.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •