pl/sql use tablename as cursor variable
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: pl/sql use tablename as cursor variable

  1. #1
    Join Date
    Aug 2000
    Posts
    143
    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;
    BEGIN
    OPEN tableName_cur;
    LOOP
    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
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    Your question has already been answered in a duplicate thread http://www.dbasupport.com/forums/sho...threadid=14749 . Please refrain from posting the same question in multiple forums in the future.
    Jeff Hunter
    marist89@yahoo.com
    http://marist89.blogspot.com/
    Get Firefox!
    "I pledge to stop eating sharks fin soup and will not do so under any circumstances."

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