0

which should be the IF condition when the variable assignation results from an empty resultset?

Example:

CREATE OR REPLACE Function get_values
     ( chv_input IN varchar2 )
     RETURN varchar2
IS
     chv_output varchar2(100);

  BEGIN

select 'value'
    into chv_output
from dual where 1=2; 

IF chv_output is null THEN --this condition is not working

    chv_output := 'null';

ELSE
     chv_output := 'not null';

END IF;

  RETURN chv_output;

END;

--select 1, get_values('112') from dual

1 Answer 1

2

Try this instead:

EXCEPTION
WHEN NO_DATA_FOUND
  chv_output := 'null';
Sign up to request clarification or add additional context in comments.

1 Comment

great. I used just after the select. Like this: select 'value' into chv_output from dual where 1=2; EXCEPTION WHEN NO_DATA_FOUND THEN NULL;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.