|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Run DB2 export command in loop
Hi All, I have list of 100 table names in a file, how to read table name from and pass to DB2 export command and run for all tables in loop. Please help me with script. Code:
db2 EXPORT TO ~/data_export/<table name from file>.ixf OF IXF MESSAGES messages.txt "SELECT * FROM ITG.<Table Name from file>" Thanks Srimitta Last edited by Scott; 08-04-2010 at 06:55 PM.. Reason: Added code tags |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Code:
$ cat file_with_table_names
table1
table2
table3
$ xargs -I{} echo db2 EXPORT TO \~/data_export/{}.ixf OF IXF MESSAGES messages.txt \"SELECT \* FROM ITG.{}\" < file_with_table_names | shLast edited by Scott; 08-04-2010 at 06:26 PM.. |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Hi Scott, Thanks for the reply. I ran script and getting below error message, any idea. Code:
$ ksh -x export_db2_tables.ksh
+ cd /home/db2inst2/data_export/scripts/
+ cat table_names
table1
table2
table3
+ db2 connect to ITG
Database Connection Information
Database server = DB2/AIX64 9.5.2
SQL authorization ID = DB2INST1
Local database alias = ITG
+ xargs -I{} db2 EXPORT TO ~/data_export/{}.ixf OF IXF MESSAGES messages.txt "SELECT * FROM ITG.{}"
+ 0< table_names
+ sh
sh: SQL0104N: not found.
sh[2]: found: not found.
sh[4]: SQL0104N: not found.
sh[5]: found: not found.
sh[7]: SQL0104N: not found.
sh[8]: was: not found.Thanks Srimitta Last edited by Scott; 08-04-2010 at 06:56 PM.. Reason: Added code tags |
|
#4
|
||||
|
||||
|
Hi. Sorry about that ![]() Code:
while read TABLE; do db2 EXPORT TO ~/data_export/$TABLE.ixf OF IXF MESSAGES messages.txt "SELECT * FROM ITG.$TABLE" done < file_with_table_names My globbing brain is not engaged! If it doesn't work, try changing * to \* |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Thanks Scott, Excellent it's working.
Srimitta |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Export Command | chpraveen_862 | Shell Programming and Scripting | 3 | 03-19-2009 04:29 AM |
| awk/sed Command : Parse parameter file / send the lines to the ksh export command | rajan_san | Shell Programming and Scripting | 4 | 11-06-2008 12:29 PM |
| Export command | prakash.kudreka | UNIX for Advanced & Expert Users | 3 | 11-20-2007 07:37 AM |
| export command | radhika03 | UNIX for Dummies Questions & Answers | 2 | 12-16-2005 08:25 AM |
| using export command | sveera | Shell Programming and Scripting | 4 | 04-01-2005 10:05 AM |
|
|