Quote:
Originally posted by anuragmin
Hi,
I am totally new to writing shell scripts.
What I want to do is that i want to do a conditional load of data from a flat file onto a table.
The data looks something like this
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
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