存储过程取不到值怎么处理?
select nvl(c.c_id, '0')
into warn_id
from t_config c
right join (select '0' from dual) tt on 1 = 1
where risk_val between c.start_val and c.end_val;
warn_id,risk_val都是过程中定义的变量,但是risk_val可能不在config表中start_val与end_val之间,返回空行,为了避免这种情况,我来了个right join (select '0' from dual) tt on 1 = 1,但是还是错误啊,依然返回空行,报错,大侠们看看,怎么改改啊
------解决方案--------------------
SQL code
select nvl(c.c_id, '0')
into warn_id
from t_config c
right join (select '0' from dual) tt on 1 = 1 and risk_val between c.start_val and c.end_val;--你加入到了where中,right join对于tt失效了