Facing problem in the sqlldr & shell script | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Facing problem in the sqlldr & shell script

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-16-2012
xal_kaushi xal_kaushi is offline
Registered User
 
Join Date: Oct 2011
Last Activity: 7 June 2012, 2:30 AM EDT
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Facing problem in the sqlldr & shell script

Guys i am facing two problems :

(1) when i create the sql loader file the date format i m getting is this
28-DEC-11 12.03.14.107137 AM;
for this i m using this script but unable to load the files


Code:
trailing nullcols
(
SERIALNO,
AMOUNT,
CLASS,
MDN,
VDATE "to_date(:TIMESTAMP, 'DD-MON-YY HH24:MiS')"

)


(2) Another one is the name of the file is ERIC_VOUCHERDAT15
where 15 is the date
i want to do ftp this file from another server to my server
for this what syantax i have to use it .

Pls help mee guys

Last edited by radoulov; 01-16-2012 at 04:05 AM.. Reason: Code tags!
Sponsored Links
    #2  
Old 01-16-2012
archimedes archimedes is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 11 March 2013, 7:06 AM EDT
Posts: 13
Thanks: 1
Thanked 4 Times in 4 Posts
hi,

1) a bad file must be formed when your data is not being loaded. Can you please paste the error displayed in that? Also, try using the timestamp as :


Code:
VDATE "to_date(:TIMESTAMP, 'DD-MON-YY HH24:MiSS')"

2) In case of the files that need to be ftped, will the date only change and will it be 2 digits ?? If so, you can use - ERIC_VOUCHERDAT?? where ?? = 01,02... 31.
Else, please give a list of all diff filenames so that filepattern can be identified.

Regards,
A!

Last edited by radoulov; 01-16-2012 at 04:06 AM.. Reason: Code tags!
Sponsored Links
    #3  
Old 01-16-2012
xal_kaushi xal_kaushi is offline
Registered User
 
Join Date: Oct 2011
Last Activity: 7 June 2012, 2:30 AM EDT
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
I am tried sm other method also but

I am getting this error

SQL*Loader: Release 10.2.0.4.0 - Production on Mon Jan 16 19:52:03 2012

Copyright (c) 1982, 2007, Oracle. All rights reserved.

SQL*Loader-291: Invalid bind variable :TIMESTAMP in SQL string for column VDATE.

---------- Post updated at 09:26 AM ---------- Previous update was at 09:23 AM ----------

Quote:
Originally Posted by archimedes View Post
hi,

1) a bad file must be formed when your data is not being loaded. Can you please paste the error displayed in that? Also, try using the timestamp as :


Code:
VDATE "to_date(:TIMESTAMP, 'DD-MON-YY HH24:MiSS')"

2) In case of the files that need to be ftped, will the date only change and will it be 2 digits ?? If so, you can use - ERIC_VOUCHERDAT?? where ?? = 01,02... 31.
Else, please give a list of all diff filenames so that filepattern can be identified.

Regards,
A!
Yes dear
the format remains the same throughtout but the date change everyday
for eg today is 16-jan
the file is ERIC_VOUCHERDAT16
    #4  
Old 01-16-2012
durden_tyler's Avatar
durden_tyler durden_tyler is offline Forum Advisor  
Registered User
 
Join Date: Apr 2009
Last Activity: 31 July 2014, 2:21 PM EDT
Posts: 1,840
Thanks: 7
Thanked 265 Times in 240 Posts
Quote:
Originally Posted by xal_kaushi View Post
I am tried sm other method also but

I am getting this error

SQL*Loader: Release 10.2.0.4.0 - Production on Mon Jan 16 19:52:03 2012

Copyright (c) 1982, 2007, Oracle. All rights reserved.

SQL*Loader-291: Invalid bind variable :TIMESTAMP in SQL string for column VDATE.
...
Just specify the datatype ("timestamp") and the format in your control file and Oracle will perform the implicit conversion if your database column is a date.

An example follows:


Code:
$
$
$ # Data in table "t" before load
$
$ echo "select x, to_char(y, 'mm/dd/yyyy hh24:mi:ss') as y from t;" | sqlplus -s test/test

no rows selected

$
$
$ # Contents of my control file "t.ctl" with inline data
$
$ cat -n t.ctl
     1  load data
     2  infile *
     3  replace
     4  into table t
     5  fields terminated by ","
     6  trailing nullcols
     7  (
     8    x  integer external,
     9    y  timestamp 'DD-MON-RR HH.MI.SS.FF6 AM'
    10  )
    11
    12  BEGINDATA
    13  1,28-DEC-11 12.03.14.107137 AM
    14  2,29-DEC-11 09.23.57.123456 PM
    15  3,08-JAN-12 11.59.59.999999 PM
$
$
$ # Load data using sqlldr
$
$ sqlldr userid=test/test control=t.ctl silent=all
$
$
$ # Data in table "t" after load
$
$ echo "select x, to_char(y, 'mm/dd/yyyy hh24:mi:ss') as y from t;" | sqlplus -s test/test

         X Y
---------- -------------------
         1 12/28/2011 00:03:14
         2 12/29/2011 21:23:57
         3 01/08/2012 23:59:59

$
$

Quote:
...
...the format remains the same throughtout but the date change everyday
for eg today is 16-jan
the file is ERIC_VOUCHERDAT16
You can extract the current date from the "date" command of Unix/Linux, like so -


Code:
$
$ date '+%d'
16
$
$

Assign this to a shell variable and use that variable in your filename within the ftp command-list. Or you could use the output of the command above directly in your filename.

HTH,
tyler_durden
Sponsored Links
    #5  
Old 01-17-2012
archimedes archimedes is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 11 March 2013, 7:06 AM EDT
Posts: 13
Thanks: 1
Thanked 4 Times in 4 Posts
Quote:
Yes dear
the format remains the same throughtout but the date change everyday
for eg today is 16-jan
the file is ERIC_VOUCHERDAT16
in this case as i mentioned earlier, the filepattern can be ERIC_VOUCHERDAT??, where ??=01,02,03....
If you have a configuration file, you can use this file pattern in that or directly in the shell.. it will work.

Regards,
A!
Sponsored Links
    #6  
Old 01-18-2012
xal_kaushi xal_kaushi is offline
Registered User
 
Join Date: Oct 2011
Last Activity: 7 June 2012, 2:30 AM EDT
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by durden_tyler View Post
Just specify the datatype ("timestamp") and the format in your control file and Oracle will perform the implicit conversion if your database column is a date.

An example follows:


Code:
$
$
$ # Data in table "t" before load
$
$ echo "select x, to_char(y, 'mm/dd/yyyy hh24:mi:ss') as y from t;" | sqlplus -s test/test

no rows selected

$
$
$ # Contents of my control file "t.ctl" with inline data
$
$ cat -n t.ctl
     1  load data
     2  infile *
     3  replace
     4  into table t
     5  fields terminated by ","
     6  trailing nullcols
     7  (
     8    x  integer external,
     9    y  timestamp 'DD-MON-RR HH.MI.SS.FF6 AM'
    10  )
    11
    12  BEGINDATA
    13  1,28-DEC-11 12.03.14.107137 AM
    14  2,29-DEC-11 09.23.57.123456 PM
    15  3,08-JAN-12 11.59.59.999999 PM
$
$
$ # Load data using sqlldr
$
$ sqlldr userid=test/test control=t.ctl silent=all
$
$
$ # Data in table "t" after load
$
$ echo "select x, to_char(y, 'mm/dd/yyyy hh24:mi:ss') as y from t;" | sqlplus -s test/test

         X Y
---------- -------------------
         1 12/28/2011 00:03:14
         2 12/29/2011 21:23:57
         3 01/08/2012 23:59:59

$
$



You can extract the current date from the "date" command of Unix/Linux, like so -


Code:
$
$ date '+%d'
16
$
$

Assign this to a shell variable and use that variable in your filename within the ftp command-list. Or you could use the output of the command above directly in your filename.

HTH,
tyler_durden
Thnks Buddy
the issue is resolved .........thanks a lot

---------- Post updated at 05:00 AM ---------- Previous update was at 04:49 AM ----------

Quote:
Originally Posted by xal_kaushi View Post
Thnks Buddy
the issue is resolved .........thanks a lot


I want a little more help
when i am running the script for loading the data .Before the data there a some charters which i dont want to insert for removing them what syntax i should use.

awk or sed

eg ---
SQL*Plus:Release11.1.0.6.0-ProductiononThuDec2917:47:002011

Copyright(c)1982,2007,Oracle.Allrightsreserved.


Connectedto:
OracleDatabase11gEnterpriseEditionRelease11.1.0.6.0-64bitProduction
WiththePartitioning,RealApplicationClusters,OLAP,DataMining
andRealApplicationTestingoptions

SQL>SQL>SQL>SQL>SQL>23456

55570000264691;1269; LN56;8765566051;28-DEC-1112.03.14.107137AM; Used
55570000248704;1269; LN56;8765291330;28-DEC-1101.10.32.909514AM; Used


I have to remove this lines which are coloured
and i have to insert the which is in csv format
Regards
Kaushal
Sponsored Links
    #7  
Old 01-18-2012
durden_tyler's Avatar
durden_tyler durden_tyler is offline Forum Advisor  
Registered User
 
Join Date: Apr 2009
Last Activity: 31 July 2014, 2:21 PM EDT
Posts: 1,840
Thanks: 7
Thanked 265 Times in 240 Posts
Quote:
Originally Posted by xal_kaushi View Post
... i am running the script for loading the data .Before the data there a some charters which i dont want to insert for removing them what syntax i should use.

awk or sed

eg ---
SQL*Plus:Release11.1.0.6.0-ProductiononThuDec2917:47:002011

Copyright(c)1982,2007,Oracle.Allrightsreserved.


Connectedto:
OracleDatabase11gEnterpriseEditionRelease11.1.0.6.0-64bitProduction
WiththePartitioning,RealApplicationClusters,OLAP,DataMining
andRealApplicationTestingoptions

SQL>SQL>SQL>SQL>SQL>23456
55570000264691;1269; LN56;8765566051;28-DEC-1112.03.14.107137AM; Used
55570000248704;1269; LN56;8765291330;28-DEC-1101.10.32.909514AM; Used


I have to remove this lines which are coloured
and i have to insert the which is in csv format
...
Use the "-s" or "silent" option with sqlplus. It suppresses the display of the blurb and prompts.


Code:
sqlplus -s <user>/<password>@<db_connect_identifier>

Or better still -


Code:
sqlplus -s /nolog <<EOF
connect <user>/<password>@<db_connect_identifier>
-- your stuff here (sqlplus settings, DML etc)
exit
EOF

Have a look at the output of "sqlplus --help" for more information.

tyler_durden
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem facing command using shell jojo123 Shell Programming and Scripting 1 08-21-2011 07:55 AM
sqlldr in shell script vinoth_kumar Shell Programming and Scripting 7 07-29-2011 10:58 AM
Shell con sqlldr marcoinxs Shell Programming and Scripting 0 08-14-2009 11:21 AM
facing problem in starting a process in background using shell script. dtomar Shell Programming and Scripting 8 04-17-2008 08:11 AM
Facing issue in Solaris OS in crontab for running shell script mabrar Shell Programming and Scripting 2 11-02-2007 06:32 AM



All times are GMT -4. The time now is 12:29 AM.