0

我有基本查询:

select col1, nvl(col1,to_number(null)) from table1 where colx = :new

更新

基本上,在上传期间我正在检查是否:new在里面table1.colx。如果是,我想显示col1,如果不是null值(我不能放零)。

4

3 回答 3

2

nvl(col1,to_number(null)) 将返回空白。您可以将其更改为:nvl(col1,0)。

于 2016-10-26T09:56:24.077 回答
0

当 colx = 'abcde' 不在 table1 中时,您的查询将引发 no_data_found 异常。它不会从您的查询中返回结果。

您可以捕获此异常并对其采取行动。

于 2016-10-26T09:57:43.117 回答
0

在您的pl/sql中,您需要处理查询结果返回0行的情况,即异常处理:

BEGIN
 ...
 select col1 into my_variable from table1 where colx = :new;
 ...
EXCEPTION WHEN NO_DATA_FOUND then
 <whatever-code-when-there-is-no-data>
 ...
END;
于 2016-10-26T14:18:12.023 回答