简体   繁体   English

Oracle NVL即使使用不为空也无法处理空字符串

[英]Oracle nvl not able to handle empty string even after using is not null

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. 如果选择查询返回null我试图返回null字符串或哑字符串。我尝试在NVL(colum,'dummy')使用哑值,但仍然no data found错误。 Below is what I tried: 以下是我尝试的方法:

1. 1。

  SELECT de.destination INTO l_sub_ent

  FROM dest de

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

2. 2。

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

  FROM dest de

  where de.destination ='some value'; 

3. 3。

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

  FROM dest de

  where de.destination ='some value'; 

Problem is not that your de.destination is NULL . 问题不是您的de.destinationNULL There are no records for the condition de.destination='somevalue' . 没有条件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; 

I was able to solve using below : 我可以使用以下方法解决:

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

  FROM dest de

  where de.destination ='some value'; 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM