Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQLLOADER Format FIELD

Status
Not open for further replies.

jestrada101

Technical User
Mar 28, 2003
332
Is there a method to do the following with SQL Loader?

I have a field column DURATION field in a flat file that is like the following.

24642300 which is H:MM:SS = 2:46:42

Is there a way to have SQL Loader convert this into seconds before it gets loaded?

I do not care to include the remaining three digits.

THANKS for any ideas...
JE
 
JE,

The following works for me:

create table tst ( tst NUMBER )

--- input file
24642300

--- ctl file
LOAD DATA
APPEND INTO TABLE tst
FIELDS TERMINATED BY ','
(
tst "substr:)tst,0,1)*60*60 + substr:)tst,2,2)*60 + substr:)tst,4,2)"
)

After running SQL*Loader the table holds the value 10002.

Regards,
Dan
 
That is exactly what I need to do, but i'm using positions to terminate each field... How can I implement that? This is how my control file looks...

DURATION position (108:115) CHAR(8),
EXAMPLE position (117:120) CHAR(4),
.....
.
.

Thanks!
 
JE,

The following control file is working for me:

LOAD DATA
APPEND INTO TABLE tst
(
tst position(1:8) char(8) "substr:)tst,0,1)*60*60 + substr:)tst,2,2)*60 + substr:)tst,4,2)"
)

After making the name and position adjustments it should work for you as well.

Regards,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top