Shell script and sql

Hi,

I have an issue. There is a file that has got some values seperated by commas. I have to write a shell script that would extrct these values and insert them into a table. How can this be done

Thanx in advance

Use sqlldr

I use something as follows in my shell script.

        sqlldr $\{DBUSER\}/$\{DBPASS\}@$\{ORACLE_SID\} \\
                    data=$\{INFILE\}.data \\
                    bad=$\{INFILE\}.bad \\
                    control=$\{CTLFILE\} \\
                    log=$\{INFILE\}.log > /dev/null 2>&1

Here, DBUSER,DBPASS and ORACLE_SID are self explanatory.

${INFILE}.data is the actual data file that you have with comma separated values.
${INFILE}.bad will be the file generated with records which were not inserted in the table.
${CTLFILE} is the control file which contains information about how the data is to be loaded. One example is as follows.
my_table.ctl
-----------------------------------------------------
LOAD DATA
INFILE 'use_parameter_value'
BADFILE 'use_parameter_value'
APPEND
INTO TABLE My_Table
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY '"'
trailing nullcols
(
name
,address
,username
,password
)
-------------------------------------------------------

${INFILE}.log is the file where the logs for the operations done by sqlldr are written.

Rahul.

I have my values in a file called 'val'. when I followed the same procedure It tells me that "unable to open val.dat : No such file or directory." I'm trying to do this from the same directory where my file with values and control file are there.
Please help me out.

Thanx in advance

Please specify the command yu are giving. I assume you are passing data=val.dat, but you should pass 'val' as your filename is val itself.

Rahul.