我在表中有“说明(VARCHAR2)”列:
No| Explanation
1 | Shipment of cabbage by agreement 29.04.2019 TAX Free
2 | Payment for screws (01.04.19) Tax: 13.55 %
3 | For reserch by deal dated 01.01.2015 Tax free
4 | Tax payment for the may 2019
我需要查询来回答“条目中是否有某种形式的日期?”是/否每个条目。在Oracle 9i上可以吗?
我尝试了一些解决方案。但遇到了问题:
“ ORA-01858:在需要数字的位置找到了非数字字符”。
我现在不清楚日期戳在哪里。
select to_char(to_date(EXPLANATION, 'DD.MM.YYYY')) from PAYMENTDOC
答案 0 :(得分:0)
您可以使用正则表达式执行此操作。尝试以下代码:
select No, Explanation,
case when regexp_instr(Explanation,'\d{2}.\d{2}.\d{2}')!=1 then
'Y'
when regexp_instr(Explanation,'\d{2}.\d{2}.\d{4}')!=1 then
'Y'
when REGEXP_instr(Explanation, '(January|February|March|April|May|June|July|August|September|October|November|December) [0-9]{4}')!=1 then
'Y'
END Does_entry_have_a_date_in_some_form_in_it
from table_name;
输出:
No| Explanation | Does_entry_have_a_date_in_some_form_in_it
1 | Shipment of cabbage by agreement 29.04.2019 TAX Free | Y
2 | Payment for screws (01.04.19) Tax: 13.55 % | Y
3 | For reserch by deal dated 01.01.2015 Tax free | Y
4 | Tax payment for the may 2019 | Y