我有麻煩編譯如下功能的Oracle甲骨文 - PLS-00382:表達式是錯誤的類型在減去日期
CREATE OR REPLACE FUNCTION fn1
return binary_double
as
Fecha DATE;
Dias binary_double;
begin
dbms_output.put_line(CAST(TRUNC(CURRENT_DATE,'DD') AS DATE) - cast(current_timestamp as date));
return Dias;
end;
它導致錯誤
Error(8,27): PLS-00382: expression is of wrong type
但是外跑同樣的表情函數體
select CAST(TRUNC(CURRENT_DATE,'DD') AS DATE) - cast(current_timestamp as date) from dual
給出預期結果 - 兩個日期之間的天數
-0.0607060185185185185185185185185185185185
有什麼想法可能是錯誤的功能?