Oracle日期格式问题

时间:2017-04-24 13:46:07

标签: sql oracle plsql

有解决方法吗?我必须将日期作为输入并在PL-SQL过程中执行它。

ref_d := '03042017';

select  count(*) into count_num 
from    EGB_RDMS_RULE
where   ref_d = to_date('03042017','DDMMYYYY'); -- This statement works 

select  count(*) into count_num2
from    EGB_RDMS_RULE
where   ref_d = to_date(ref_d,'DDMMYYYY'); -- This doesnt work 

有人可以解释为什么第二个陈述不起作用?

2 个答案:

答案 0 :(得分:3)

我怀疑ref_d是您表格中的一栏。

我总是在局部变量前加上一些东西来表示它们不是列。所以,我怀疑你想要这样的东西:

v_ref_d := '03042017';

select  count(*) into count_num2
from    EGB_RDMS_RULE
where   ref_d = to_date(v_ref_d, 'DDMMYYYY');

答案 1 :(得分:2)

尝试在函数外部调用ref_d!这可能有用

相关问题