1

I am trying to return empty or dummy string if select query returns null.I tried using dummy value in NVL(colum,'dummy'), but I am still getting no data found error. Below is what I tried:

1.

  SELECT de.destination INTO l_sub_ent

  FROM dest de

  where de.destination='somevalue' AND de.destination IS NOT NULL; 

2.

  SELECT COALSECE(de.destination, 'dummy') INTO l_sub_ent

  FROM dest de

  where de.destination ='some value'; 

3.

  SELECT NVL(de.desc_en, 'dummy') INTO l_sub_ent

  FROM dest de

  where de.destination ='some value'; 

2 Answers 2

2

Problem is not that your de.destination is NULL. There are no records for the condition de.destination='somevalue'. Handle it something like this.

SELECT Count(1)
INTO   v_count
FROM   dest de
WHERE  de.destination='somevalue';

IF v_count > 0 THEN
  SELECT NVL(de.destination,'dummy')
  INTO   l_sub_ent
  FROM   dest de
  WHERE  de.destination='somevalue';
END IF; 
Sign up to request clarification or add additional context in comments.

Comments

0

I was able to solve using below :

SELECT NVL(MIN(val), 'dummy') INTO l_sub_ent

  FROM dest de

  where de.destination ='some value'; 

Comments

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.