Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Convert Char To Number

Angus123Oct 26 2021

Hi
I have a column which is a CHAR(40).
It contains data like 20210930 or data like 2021-08-11 00:00:00.000 +02:00.
I want to convert to a number like 20210930 or 20210811
This works
SELECT TO_NUMBER(TO_CHAR(TO_DATE('20210930','YYYYMMDD'), 'YYYYMMDD')) FROM dual;
How do I convert it to a number like 20210811
I have tried
SELECT TO_NUMBER(TO_CHAR(TO_DATE('2021-08-11 00:00:00.000 +02:00','YYYYMMDD'), 'YYYYMMDD')) FROM dual;
and several variations but always seem to get an error
Ora-01843 Not a valid month
Regards
Gus

This post has been answered by Frank Kulash on Oct 26 2021
Jump to Answer

Comments

I moved this to the ODI forum....

User_9AGUD

Someone has comment on this. Thanks

Marco Fris

Depends on your definition of 'good' data.
If you can express your criteria in terms of database constraints (uniqueness, referential constraints, check constraints) then ODI's CKMs can help. A CKM verifies incoming data against those constraints and puts records that violate any into an error table. Basic but effective.
They appear to have been omitted in recent documentation, but to my knowledge this older guide is still valid.
Have fun, Marco

User_9AGUD

Thanks Marco. How to implement The rows failing the conditions will be inserted in an error table which are prefixed by E$_? Which IKM can I use? Does IKM exist or not?
Thanks a lot
Loan

Marco Fris

Hi Loan,
It is the CKM that does that. You can select it in the same way you pick you IKM: on the physical tab of your mapping with the target selected.
Did you spot the link to the tutorial? https://docs.oracle.com/cd/E21043_01/integrate.1111/e12641/quality.htm

Have fun, Marco

et4891

Hello Loan,
If you aren't able to find any IKM which I had a hard time finding it so made a post https://community.oracle.com/tech/apps-infra/discussion/4484961/import-create-integration-knowledge-modules
Look at the answer accepted, thanks to @marco-fris3 for helping me out finding where to import

ET

1 - 6

Post Details

Added on Oct 26 2021
3 comments
7,721 views