Hi,
I am new to Shell Scripting, and I need to create nicknames for 600 tables in db2. I have the file names in a text file and i have to pass these table names to a shell script create nicknames in db2. Can some one please help me in this regard.
Hi,
I am new to Shell Scripting, and I need to create nicknames for 600 tables in db2. I have the file names in a text file and i have to pass these table names to a shell script create nicknames in db2. Can some one please help me in this regard.
Easier to give script solution if you give:
-example from file format
-how to do nickname sqlcmd
-db2 interpreter cmd syntax
I have not used db2 = don't know db2 interpreter syntax, but here is basic model to do it.
If file format is:
table1 nickname1
table2 nickname2
...
Run cmd format:
./nick2db2 somefile.txt
Then something like (nick2db2):
#!/usr/bin/ksh
# or bash or dash or
#nick2db2
nicknames="$1"
> donick.sql
while read table nickname xstr
do
echo "SOMEDB2CMD '$table' '$nickname' ;" >> donick.sql
done < "$nicknames"
echo "
-- commit or ...
COMMIT;
" >> donick.sql
echo "Use db2 sql interpreter to run this donick.sql sqlfile"
After created nick2db2, give execute priviledges
chmod a+rx nick2db2