日期:2014-05-20  浏览次数:20809 次

还是sql问题,两次调用自定义function结果如何求和?
我这儿有个大sql如下,逻辑倒也简单
SQL code

select case
         when '1' = '1' and '2011-05-29' is not null and
         (calInteval(to_date('2009-09-28', 'yyyy-mm-dd'),to_date('2011-05-29', 'yyyy-mm-dd')) <= 180 or
         (calInteval(to_date('2010-12-01', 'yyyy-mm-dd'),to_date('2011-05-29', 'yyyy-mm-dd')) > 0 and 
          calInteval(to_date('2010-12-01', 'yyyy-mm-dd'),to_date('2011-05-29', 'yyyy-mm-dd')) <= 180)) then
          (select GETSUMSTANDMONEY('2009002993778021', date'2011-05-29') from LDSysVar where SysVar = 'onerow' + 
           select GETSUMSTANDMONEY('2009002993779021', date'2011-05-29') from LDSysVar where SysVar = 'onerow'
          ) 
       else
          0
       end
from dual



其中这两行代码
SQL code

select GETSUMSTANDMONEY('2009002993778021', date'2011-05-29') from LDSysVar where SysVar = 'onerow' + 
           select GETSUMSTANDMONEY('2009002993779021', date'2011-05-29') from LDSysVar where SysVar = 'onerow'



GETSUMSTANDMONEY 是个自定义的function ,单独执行每一条语句都可以得到结果,而且返回值是number型的,
但是那样加起来就报错。大侠们帮看看。

------解决方案--------------------
多加两重括号试试看?

((select GETSUMSTANDMONEY('2009002993778021', date'2011-05-29') from LDSysVar where SysVar = 'onerow') + (select GETSUMSTANDMONEY('2009002993779021', date'2011-05-29') from LDSysVar where SysVar = 'onerow'))