Oracle pl/sql code line(row) to variable

oracle, plsql

Solution

So is it possible to get current code line?

Yes, it's possible. Starting from Oracle 10g the `$$PLSQL_LINE` inquiry directive can be used to return number of a line in the code where `$$PLSQL_LINE` appears:

SQL> declare
  2    l_cur_cl pls_integer;
  3  begin
  4    l_cur_cl := $$PLSQL_LINE;
  5    dbms_output.put_line('Line #: '|| to_char(l_cur_cl) || chr(13)
  6                         || 'Current line #:  '|| to_char($$PLSQL_LINE));
  7  end;
  8  /

Output:

Line #: 4
Current line #:  6
PL/SQL procedure successfully completed

Problem

So is it possible to get current code line? ``` 1,2,3,4 v_variable :=(get_line or something???) and in variable are value 4? 5,6,7,8,9 v_variable :=(get_line or something???) and in variable are value 9? ``` I just want to find easiest way to catch bugs Thanks. ``` 1,2,3,4, code lines... ```

Original source

Related problems