Oracle '从SQL Developer UI和SQL查询中调用的同一函数的不同结果

Oracle '从SQL Developer UI和SQL查询中调用的同一函数的不同结果,oracle,plsql,oracle-sqldeveloper,Oracle,Plsql,Oracle Sqldeveloper,F是一个函数,它使用'DD/MM/YYYY'[NLS_DATE_LANGUAGE=FRENCH]格式计算两个日期之间的工作日数。 它存储在P包中 其中a为该期间的开始日期,b为结束日期 当我使用SQL developer运行函数时,即右键单击包p,执行,选择f函数并填充参数: if a = to_date('02/08/2019', 'DD/MM/YYYY') and b = to_date('12/08/2019', 'DD/MM/YYYY')) 我得到的天数=7,这是正确的结果 但当我在S

F是一个函数,它使用'DD/MM/YYYY'[NLS_DATE_LANGUAGE=FRENCH]格式计算两个日期之间的工作日数。 它存储在P包中

其中a为该期间的开始日期,b为结束日期

当我使用SQL developer运行函数时,即右键单击包p,执行,选择f函数并填充参数:

if a = to_date('02/08/2019', 'DD/MM/YYYY') and b = to_date('12/08/2019', 'DD/MM/YYYY'))
我得到的天数=7,这是正确的结果

但当我在SQL中运行它时:

从双功能菜单中选择p.f‘2019年8月2日’、‘2019年8月12日’ 我得到的天数=8,这个结果显然是错误的

我无法理解这两个进程如何返回两个不同的值,因为调用了相同的F函数,并且参数完全相同

我对日期格式很小心,但调用f的两种方法不会返回相同的结果

仅供参考,这是该功能的内容对不起,cariable是用法语表示的

FUNCTION getjoursouvres
(
    i_debut IN DATE,
    i_fin IN DATE   
)
RETURN NUMBER IS o_result NUMBER;
v_jour date;
v_nbjours NUMBER;
v_testferie number;
v_testweekend number;
v_testglobal number;
-- This cursor browses all dates between i_debut and i_fin (included)
cursor cx is 
            select to_date(i_debut, 'DD/MM/YYYY') + rownum -1 dt 
            from dual 
            connect by level <= to_date(i_fin, 'DD/MM/YYYY') - to_date(i_debut, 'DD/MM/YYYY') + 1;
BEGIN
open cx;
v_nbjours := 0;
    loop
-- Browses all the days in the interval (begining and end included)
        fetch cx into v_jour;
        exit when cx%NOTFOUND;
-- testferie return 1 if the day is NOT a holiday, 0 if it is (so not be be added)
            v_testferie := testferie(v_jour);
-- testweekend return 1 if the day is a weekday, 0 if it is on weekend (so not be be 
            v_testweekend := testweekend(v_jour);
-- 
            v_testglobal := v_testferie + v_testweekend;
-- If v_testglobal = 2 then the day is neither weekend nor holiday. Therefore it is aded to the sum of days
            if v_test = 2 then
                v_nbjours := v_nbjours + 1;
            end if;
    end loop;
o_result := v_nbjours;
close cx;
return o_result;
END;

经过多次调用,两种方法都可以使用该函数。我得出的结论是,引起异常的元素来自于

to_date(v_date, 'DD/MM/YYYY')
其中v_date已声明为日期格式,其行为方式为不可预测。 我决定保留date变量,只对不同的cariable格式使用TOU date


我无法解释确切的原因,但它解决了我关于约会行为的问题。现在,我可以从DUAL或SQL developer接口调用带有数据参数的函数,并获得相同且一致的结果

请编辑您的问题以包含函数f的内容。从DUAL中选择f.pa,b-在这种情况下,a和b是什么?如果v_日期已声明为日期格式,您的意思是声明为日期吗?日期没有任何格式。