|
|
|
|
|
|
|
|
| Re: Loading date field with CCYYMMDD format using SQL*Loader [message #129987 is a reply to message #129981] |
Wed, 27 July 2005 10:15   |
Art Metzer
Messages: 2480 Registered: December 2002
|
Senior Member |
|
|
I have no problems.
Creating the table in SQL*Plus:SQL> CREATE TABLE t (
2 id NUMBER
3 , text VARCHAR2(4)
4 , dt DATE
5 )
6 /
Table created.
SQL>
The sample data file:$ cat sampledata.txt
1,QRS,20050101
2,TUV,20050715
3,WXY,21050715
4,ZAB,20040801
$
The SQL*Loader control file:$ cat sample.ctl
LOAD DATA
INFILE 'sampledata.txt'
TRUNCATE
INTO TABLE scott.t
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED '"'
TRAILING NULLCOLS (
id NULLIF id=BLANKS "TRIM(:id)"
, text NULLIF text=BLANKS "TRIM(:text)"
, dt DATE "YYYYMMDD" "TRIM(:dt)"
)
$
The SQL*Loader call:$ sqlldr scott/tiger control=sample.ctl
SQL*Loader: Release 8.0.6.3.0 - Production on Wed Jul 27 11:03:43 2005
(c) Copyright 1999 Oracle Corporation. All rights reserved.
Commit point reached - logical record count 4
$
And finally, a SELECT from SQL*Plus proving that the DATEs were loaded successfully:SQL> SELECT t.id
2 , t.text
3 , TO_CHAR(t.dt
4 , 'fmDy DD-MON-YYYY HH:fmMI:SS AM') stored_date
5 FROM t
6 /
ID TEXT STORED_DATE
---------- ---- ---------------------------
1 QRS Sat 1-JAN-2005 12:00:00 AM
2 TUV Fri 15-JUL-2005 12:00:00 AM
3 WXY Wed 15-JUL-2105 12:00:00 AM
4 ZAB Sun 1-AUG-2004 12:00:00 AM
SQL>
|
|
|
|
|
|
| Re: Loading date field with CCYYMMDD format using SQL*Loader [message #132748 is a reply to message #130493] |
Mon, 15 August 2005 23:52   |
dhaval_khamar
Messages: 4 Registered: June 2005 Location: Bangalore
|
Junior Member |

|
|
Hi Guyz,
Thanks for all replies. I got a very easy solution....Use RRYYMMDD format, since CCYYMMDD format is nly to read records.
$ cat sample.ctl
LOAD DATA
INFILE 'sampledata.txt'
TRUNCATE
INTO TABLE scott.t
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED '"'
TRAILING NULLCOLS (
id NULLIF id=BLANKS "TRIM(:id)"
, text NULLIF text=BLANKS "TRIM(:text)"
, dt DATE "RRYYMMDD" "TRIM(:dt)"
)
If you see the results posted by Art Metzer, for 21050715, the year created is 2105, what we want is 2005. and this could be achived by above control file.
Regards,
Dhaval Khamar
|
|
|
|
|
|