2010-05-11T18:57:15.000Z
It's fairly easy to create such a representation using Oracle's to_char() function, but you need to use double-quote characters:
SQL> select to_char(sysdate,'YYYY-MM-DD"T"HH24:MI:SS".000Z"') from dual;
TO_CHAR(SYSDATE,'YYYY-MM-DDT
----------------------------
2010-05-11T18:57:15.000Z
However, it's a bit trickier to import a text file using Oracle's sqlldr using a "date mask". These sqlldr masks must be enclosed in double-quote characters. But this obviously confuses sqlldr, since it not expecting double-quotes within the mask. Using single quotes, either within the mask or to delimit the mask, also fails.
It turns out that you can use backslashes to escape the double-quotes within a sqlldr date mask. Here is an example sqlldr control file that demonstrates this mask, used to import a Salesforce-generated CSV file:
OPTIONS(DIRECT=true)
LOAD DATA
INFILE 'salesforce_export.csv'
APPEND
INTO TABLE salesforce_export
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
(
ID,
EMAIL,
CREATEDDATE DATE "YYYY-MM-DD\"T\"HH24:MI:SS\".000Z\"",
CREATEDBYID,
YADA__C,
YADA_YADA__C,
YADA_YADA_YADA__C
)
LOAD DATA
INFILE 'salesforce_export.csv'
APPEND
INTO TABLE salesforce_export
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
(
ID,
EMAIL,
CREATEDDATE DATE "YYYY-MM-DD\"T\"HH24:MI:SS\".000Z\"",
CREATEDBYID,
YADA__C,
YADA_YADA__C,
YADA_YADA_YADA__C
)
No comments:
Post a Comment