pl/sql use tablename as cursor variable Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: pl/sql use tablename as cursor variable

  1. #1
    Join Date
    Aug 2000
    Im trying to write a procedure that will return the rowcount of any table whose name is supplied as avariable to the function. I know it is possible to include a variable in the where clause of a cusor but I seem to have problems including a variable in the from clause:

    create or replace procedure RowComparison is
    cursor tableName_cur is
    select table_name from user_tables;
    raph1count number;
    t4count number;
    tableName_rec tableName_cur%ROWTYPE;
    OPEN tableName_cur;
    FETCH tableName_cur into tableName_rec;
    EXIT WHEN tableName_cur%NOTFOUND;
    select count(*) into raph1count from tableName_rec. table_name;

    I get the same problem if I try to rewrite this using an explicit cursor.

    The error I get is this:
    PLS-00356: 'TABLENAME_REC.TABLE_NAME' must name a table to which the user has access

    Can anyone help?

  2. #2
    Join Date
    Jan 2001
    variabletext := 'select count(*) from '||tableName_rec. table_name;

    execute immediate variabletext into raph1count ;


  3. #3
    Join Date
    Aug 2000
    Thanks vijay

Posting Permissions

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

Click Here to Expand Forum to Full Width