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!

Continue program execution if not data found

user5108636Feb 15 2017 — edited Feb 16 2017

Hi All,

     Please find the function below. Need to conitinue program execution after the no data found exception to try another query. Do suggest how to accomplish this.

FUNCTION find_number(

      p_id VARCHAR2,

      p_flag_id  VARCHAR2)

    RETURN VARCHAR2

  IS

    v_number VARCHAR2(20);

 

  BEGIN

  SELECT ru.id INTO v_number

      FROM employees ru

      WHERE ru.id = NVL(p_id, ru.id);

--to check for no data found and try another query logic before retuning the v_number

    RETURN v_number;

/If not data returned then try another query

EXCEPTION

WHEN NO_DATA_FOUND

THEN

RETURN(‘The employee is not in the database');

WHEN OTHERS

THEN

RETURN(‘Error ');

  END find_number;

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 16 2017
Added on Feb 15 2017
7 comments
3,229 views