3

I am a creating control file dynamically when my shell script runs, with:

echo 'LOAD DATA'                             > $CTLDIR/test.ctl
echo 'TRUNCATE'                              >> $CTLDIR/test.ctl
echo 'INTO TABLE TEMP'                       >> $CTLDIR/test.ctl
echo 'FIELDS TERMINATED BY ","'              >> $CTLDIR/test.ctl
echo 'TRAILING NULLCOLS'                     >> $CTLDIR/test.ctl
echo '('                                     >> $CTLDIR/test.ctl
echo 'NO, '                                  >> $CTLDIR/test.ctl
echo 'I_NUM , '                              >> $CTLDIR/test.ctl
echo 'QTY  , '                               >> $CTLDIR/test.ctl
echo 'CREATE_DATETIME       SYSDATE'         >> $CTLDIR/test.ctl
echo ')'                                     >> $CTLDIR/test.ctl

When I execute my shell script I get error "Expected keyword INTO, found keyword LOAD."

Please help me in resolving this.

Alex Poole
  • 183,384
  • 11
  • 179
  • 318
user3195273
  • 193
  • 1
  • 5
  • 13
  • You haven't shown how you're calling SQL\*Loader, or what the generated control file actually looks like (though that seems like it should be OK). What debugging have you done? – Alex Poole Jun 16 '15 at 08:26
  • Maybe you can show the whole script then, along with the output from running it, and a log file if one is produced. From the call you showed in a comment (please edit that into the question too) that call looks OK, so maybe you're overwriting the control file later in the script, or can't overwrite the control file in the first place. More information is needed. – Alex Poole Jun 16 '15 at 11:57

1 Answers1

0

Your controlfile looks OK. How are you using SQL*Loader?

You could start it with a command like this:

sqlldr control=$CTLDIR/test.ctl userid=[username]/[password]@[connect string]
  • this is how i am using sqlldr $test control=$CTLDIR/test.ctl data=$INDIR/${fileName} log=$sqlldrLog. where $test contains user_id/password. – user3195273 Jun 16 '15 at 09:58
  • This should work. Which version of sql*loader do you use? – Edward Orlowski Jun 16 '15 at 10:49
  • $ sqlldr testuser/testuser control=test.ctl data=test.data SQL*Loader: Release 11.2.0.2.0 - Production on Di Jun 16 12:48:44 2015 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. Commit point reached - logical record count 1 – Edward Orlowski Jun 16 '15 at 10:49