It is in a fixed length format. I want to load only those records in which the 3rd field starting fom 21st column and ending at 30th is "REGROLL" or "REGROLL2" .
Please Help me out.
Thanks
Anurag
Appreciation is a wonderful thing;
It makes what is excellent in others belong to us as well.
It is in a fixed length format. I want to load only those records in which the 3rd field starting fom 21st column and ending at 30th is "REGROLL" or "REGROLL2" .
Please Help me out.
Thanks
Anurag
Oracle has a utility called sql loader which allows a user to load data from a flat file into a table. The syntax is as follows
sqlldr username/password contol=load.ctl
the layout for the load.ctl file is as follows
Load Data
infile *
choose one of the following options (truncate,append,replace)
into table (table_name)
when (21:30) = 'regroll' or (21:30) = 'regroll2)
(column_name postion(x:x)
... continue to enter the record format
...
)
BEGINDATA
MBOC YR_1991 REGROLL BSPSIEB 1.000000 1.000000
ALLEP YR_1991 REGROLL COFYE 24.000000 24.000000
ALLEP YR_1991 REGROLL1 COLOP 48.000000 48.000000
ALLEP YR_1991 REGROLL2 COEPAM 8.000000 8.000000
Originally posted by JUNE
Load Data
infile *
choose one of the following options (truncate,append,replace)
into table (table_name)
when (21:30) = 'regroll' or (21:30) = 'regroll2)
(column_name postion(x:x)
... continue to enter the record format
...
)
BEGINDATA
MBOC YR_1991 REGROLL BSPSIEB 1.000000 1.000000
ALLEP YR_1991 REGROLL COFYE 24.000000 24.000000
ALLEP YR_1991 REGROLL1 COLOP 48.000000 48.000000
ALLEP YR_1991 REGROLL2 COEPAM 8.000000 8.000000
Hi,
Sql Loader does not support the OR operator and thats teh reason I need to use a shell script.
Please see my other thread where I had the same question for sql loader
In the earlier thread, the solution to Anurag's problem suggested by Jurij works fine, but only if you use a fixed format input file with a control file like the following:
LOAD DATA
INFILE *
APPEND
INTO TABLE tt
WHEN C3 = 'REGROLL'
FIELDS TERMINATED BY WHITESPACE
(c1,c2,c3,c4,c5,c6)
INTO TABLE tt
WHEN C3 = "REGROLL2"
FIELDS TERMINATED BY WHITESPACE
(c1 POSITION(1),c2,c3,c4,c5,c6)
BEGINDATA
MBOC YR_1991 REGROLL BSPSIEB 1,000000 1,000000
ALLEP YR_1991 REGROLL COFYE 24,000000 24,000000
ALLEP YR_1991 REGROLL1 COLOP 48,000000 48,000000
ALLEP YR_1991 REGROLL2 COEPAM 8,000000 8,000000
Note the POSITION(1) keyword after the first column specification for the second table load. This is neccesary for SQL*Loader to know that the field c1 in second table load begins at position 1 in the data line, othervise it would search for it after the field c6 in the first table load.
Jurij Modic ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
But my problem is that I need to replace YR_1996 to 1996 in the output.
The data looks something like this
MBOC YR_1991 REGROLL1 BSPSIEB 1.000000 1.000000
ALLEP YR_1991 REGROLL2 COFYE 24.000000 24.000000
ALLEP YR_1997 REGROLL COLOP 48.000000 48.000000
ALLEP YR_1996 REGROLL COEPAM 8.000000 8.000000
I want to select only the records in which the year is greater than 1996 and also in the process replace YR_1991 with 1991 to be inserted in the database.
Please Please Help.
Thanks
Anurag
[Edited by anuragmin on 06-15-2001 at 01:58 PM]
Appreciation is a wonderful thing;
It makes what is excellent in others belong to us as well.
Bookmarks