Question: I am executing a stored procedure but it is failing at some point, 
Current error code is not helping me to find where and exactly what the error is
I wanted to know where it is exactly failing so wanted to print line by line output while executing. 
for eg : 

```
    create or replace
    -- decaring required variable
    PROCEDURE "PROC_DATA_TABLE_DETAILS" IS
    FOR TABLEDETAILS IN (SELECT * FROM user_tables )
        LOOP

 dbms_output.put_line (TABLENAME);

    select NUM_ROWS INTO COUNTRECORDS from all_tables where owner not like 'SYS%'and TABLE_NAME = TABLEDETAILS.TABLE_NAME;

    FOR FIELDSDETAILS IN (SELECT * FROM USER_TAB_COLUMNS WHERE TABLE_NAME = TABLENAME)

         LOOP

FIELDNAME :=FIELDSDETAILS.COLUMN_NAME;

 dbms_output.put_line (FIELDNAME );

          execute immediate 'SELECT NVL(count(*),0) FROM ' ||TABLENAME || ' WHERE '|| FIELDNAME || ' is not null ' into TEMPNONBLANK;
    END LOOP;

     INSERT INTO DATA_TABLE_DETAILS VALUES  (TABLEDETAILS.TABLE_NAME,COUNTFIELDS)

    END LOOP;

    END PROC_DATA_TABLE_DETAILS;

```

Answer: 
Your code will look like this; additionally you can write a procedure with autonomous transactions to log all error or logs. you will also get online code for this functionality. 

[http://log4plsql.sourceforge.net/](http://logs)

```
create or replace procedure proc_data_table_details is
  tablename    varchar2(30);
  countrecords number;
  fieldname    varchar2(30);
  tempnonblank number;
begin
  for tabledetails in (select * from user_tables where rownum < 3) loop
    tablename := tabledetails.table_name;
    dbms_output.put_line(tabledetails.table_name);
    select num_rows
      into countrecords
      from all_tables
     where owner not like 'SYS%'
       and table_name = tablename;

    for fieldsdetails in (select * from user_tab_columns where table_name = tablename) loop
      fieldname := fieldsdetails.column_name;
      dbms_output.put_line(fieldname);
      execute immediate 'SELECT NVL(count(*),0) FROM ' || tablename || ' WHERE ' || fieldname || ' is not null '
        into tempnonblank;
        dbms_output.put_line('TABLENAME :' || tablename || ' column name :' || fieldname || ' count :' || tempnonblank);
    end loop;
  end loop;
end proc_data_table_details;

```
Try to break the code to few segements. That way you will narrow down your search field. Becoz what you are trying to do is take an analytical decision about when to print.
Alternatively, if u want to print after every value assignment, you can parse the PL/SQL code as long to a variable and then loop over it until next ':=' isn't found. And then within the Loop, find the next position of ';' and substring thr. Append dbms\_output.print\_line(preceeding\_part\_of\_assignment) and then append again the remaining string.
Instead you can just use debug.