SQLLDR CTL: Load date field received in DDMonYYYY to db fields with formats of YYYYMM or MM/DD/YYYY

。_饼干妹妹 提交于 2019-12-12 04:53:24

问题


I have source date data in the format of DDMonYYYY (e.g. 25Jan2014). I am using sqlldr to load the data into various fields of two different formats (1) YYYYMM and (2) MM/DD/YYYY. How do I accomplish this? Thanks.


回答1:


I assume you are putting data into a varchar2 column, so the lines in the control file should look something like this where the data is being manipulated on the way in to change the formatting. First convert it to a date, then use to_char to format it:

,DATE_RX_WRITTEN CHAR "to_char(to_date(:DATE_RX_WRITTEN, 'DDMONYYYY'), 'YYYYMM')"

or

,DATE_RX_WRITTEN CHAR "to_char(to_date(:DATE_RX_WRITTEN, 'DDMONYYYY'), 'MM/DD/YYYY')"

If you are able to, consider making it a DATE datatype in the table instead and convert it on the way in. That way you can convert it as needed when you select it instead:

 ,DATE_RX_WRITTEN DATE "DDMONYYYY"


来源:https://stackoverflow.com/questions/26742741/sqlldr-ctl-load-date-field-received-in-ddmonyyyy-to-db-fields-with-formats-of-y

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!