Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

PL SQL function: How to print line number at which any error occure

3145733Nov 8 2016 — edited Nov 8 2016

I was writing pl sql function and face problem in error location detection.Here is a sample function:

FUNCTION my_function(data_input VARCHAR2) return   VARCHAR2 AS   ret VARCHAR2;

  v_code NUMBER;

  v_errm VARCHAR2(500);

  BEGIN

      ret := 101+data_input;  --sample error as an example

      RETURN 'Success: '||ret;

      EXCEPTION

      WHEN OTHERS THEN

      v_code := SQLCODE;

      v_errm := SUBSTR(SQLERRM, 1 , 500);

      RETURN 'Error: '||v_code||v_errm;

  END my_function;

I used also $$plsql_line, It works at a fix line.but it does not locate error line number at any where of the function.

I want to write code in a way that will locate  the line number where error occurred (so it is not fixed line/ its dynamic)
please help me.thanks

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 6 2016
Added on Nov 8 2016
6 comments
1,482 views