1

I created a PL/SQL procedure that takes the name of user and shows a list of his tables' content. The problem is that I couldn't set the cursor to accept a different table name each time and show its content. Here is my code which is not complete yet.

set serveroutput on;

create or replace procedure userTable(name dba_tables.owner%type)
is
    cursor cur is select table_name from dba_tables where owner = upper(name);
    cursor cur2(tab_name dba_tables.table_name%type) is select * from name.tab_name;
    V$FILEP UTL_FILE.FILE_TYPE;
begin
    if existUser(name) = true then
        V$FILEP := UTL_FILE.FOPEN('DIRTEST','TEST15.UTL','W');

        for x in cur loop
            UTL_FILE.PUT_LINE(V$FILEP,to_char(x.table_name));
        end loop;

        UTL_FILE.FCLOSE(V$FILEP);
    else
        dbms_output.put_line('user invalid');
    end if;
end;
/
Abra
  • 19,142
  • 7
  • 29
  • 41
  • [Dynamic cursor Oracle](https://stackoverflow.com/questions/26046482/dynamic-cursor-oracle) – Abra Nov 23 '19 at 10:17
  • [Dynamic Cursors](https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:9532687800346420948) – Abra Nov 23 '19 at 10:19
  • 1
    How are you going to list the tables' content in a loop? You would need to know the column names. You can do this using `dbms_sql` but it won't be straightforward. – William Robertson Nov 23 '19 at 10:31

0 Answers0