06-12-2008
breaking out of while loop
Hi ,
I am running this script ( pasting only error code ) to generate some ddl definition for tables . But what I want is to break out of the db2look part when the base_table is not like DIM_$TN or FACT_$TN . After this it should come back to while loop to read the next TN . I read the other threads too but still not clear .
db2 -x "select tabname from syscat.tables where tabschema='${source_schema}' and type='A'" > table_alias.lst
cat table_alias.lst | \
while read TN
do
typeset -l TN
base_table=`db2 -x "select base_tabname from syscat.tables where tabschema='${source_schema}' and tabname=upper('$TN') " `
echo ${base_table}
if [ ${base_table} != "DIM_$TN" || ${base_table} != "FACT_$TN" ] ; then
break
else
continue
fi
db2look -d ${dbname} -z ${source_schema} -t ${base_table} -e -x > VIEW.${source_schema}.$TN.${ecmdate}.sql
tr 'a-z' 'A-Z' < VIEW.${source_schema}.$TN.${ecmdate}.sql > $tmpfile_cln
cat $tmpfile_cln > VIEW.${source_schema}.$TN.${ecmdate}.sql
cat VIEW.${source_schema}.$TN.${ecmdate}.sql
Here is the sh -x part of it .
#sh -x alias_creation.shl uhcdev01 opsdm001 opsdm002
+ [[ -n 1 ]]
+ return
+ USAGE=USAGE: alias_creation.shl [Source_DBNAME-required] [Source_Schema] [Target_Schema]
+ [[ 3 -lt 3 ]]
+ dbname=uhcdev01
+ source_schema=opsdm001
+ target_schema=opsdm002
+ typeset -u dbname
+ tmpfile_tab=/tmp/tmpfile_tab
+ tmpfile_dep=/tmp/tmpfile_tab_dep
+ tmpfile_cln=/tmp/tmpfile_cln
+ tmpfile_cln1=/tmp/tmpfile_cln1
+ + date +%Y%m%d
ecmdate=20080612
+ db2 connect to UHCDEV01
Database Connection Information
Database server = DB2/AIX64 9.1.2
SQL authorization ID = DRAM
Local database alias = UHCDEV01
+ [ opsdm001 ]
+ source_schema=opsdm001
+ [ opsdm002 ]
+ target_schema=opsdm002
+ typeset -u source_schema
+ typeset -u target_schema
+ cat table_alias.lst
+ read TN
+ typeset -l TN
+ + db2 -x select base_tabname from syscat.tables where tabschema='OPSDM001' and tabname=upper('unique_provider_targ')
base_table=
+ echo
+ [ != DIM_unique_provider_targ
alias_creation.shl[65]: test: ] missing
+ != FACT_unique_provider_targ ]
alias_creation.shl[65]: !=: not found
+ continue
+ read TN
+ typeset -l TN
+ + db2 -x select base_tabname from syscat.tables where tabschema='OPSDM001' and tabname=upper('unique_provider_uhg_resp')
base_table=
+ echo
+ [ != DIM_unique_provider_uhg_resp
alias_creation.shl[65]: test: ] missing
+ != FACT_unique_provider_uhg_resp ]
alias_creation.shl[65]: !=: not found
+ continue
+ read TN
+ typeset -l TN
+ + db2 -x select base_tabname from syscat.tables where tabschema='OPSDM001' and tabname=upper('zip')
base_table=VW_ZIP
+ echo VW_ZIP
VW_ZIP
+ [ VW_ZIP != DIM_zip
alias_creation.shl[65]: test: ] missing
+ VW_ZIP != FACT_zip ]
alias_creation.shl[65]: VW_ZIP: not found
+ continue
+ read TN
+ typeset -l TN
+ + db2 -x select base_tabname from syscat.tables where tabschema='OPSDM001' and tabname=upper('zip_customer_segment')
base_table=VW_ZIP_CUSTOMER_SEGMENT
+ echo VW_ZIP_CUSTOMER_SEGMENT
VW_ZIP_CUSTOMER_SEGMENT
+ [ VW_ZIP_CUSTOMER_SEGMENT != DIM_zip_customer_segment
alias_creation.shl[65]: test: ] missing
+ VW_ZIP_CUSTOMER_SEGMENT != FACT_zip_customer_segment ]
alias_creation.shl[65]: VW_ZIP_CUSTOMER_SEGMENT: not found
+ continue
+ read TN
+ typeset -l TN
+ + db2 -x select base_tabname from syscat.tables where tabschema='OPSDM001' and tabname=upper('zip_provider_srvc')
base_table=VW_ZIP_PROVIDER_SRVC
+ echo VW_ZIP_PROVIDER_SRVC
VW_ZIP_PROVIDER_SRVC
+ [ VW_ZIP_PROVIDER_SRVC != DIM_zip_provider_srvc
alias_creation.shl[65]: test: ] missing
+ VW_ZIP_PROVIDER_SRVC != FACT_zip_provider_srvc ]
alias_creation.shl[65]: VW_ZIP_PROVIDER_SRVC: not found
+ continue
+ read TN
+ db2 terminate
Thanks in advance
10 More Discussions You Might Find Interesting
1. HP-UX
Can some one point this UNIX newbie to a web site or directions on the steps needed to break a mirror in HP-UNIX to change a bad hard drive. (4 Replies)
Discussion started by: egress1
4 Replies
2. Shell Programming and Scripting
Hey all
I have two scripts, one script containing the guts of my code.
The other simply loops through a list, calling the other script on each iteration.
Problem is when I add the line
`/usr/bin/rsh -l root $HOSTNAME ""`
to my main script, the loop never seems to exectute any more... (1 Reply)
Discussion started by: mark007
1 Replies
3. Shell Programming and Scripting
Hi friends,
I have 2 scripts. 1) Master_Script.sh and 2) Sub_script.sh
We run Master_script.sh manually where as sub_script.sh keeps generating output in every 2 minutes (through crontab). The output generated by sub_script.sh can be 0 or 1.
As I told you, sub-script.sh keeps generating o/p... (7 Replies)
Discussion started by: anushree.a
7 Replies
4. Shell Programming and Scripting
Hello Friends,
Im trying to write a script to invoke nagios. In order to do this I grep some words that comes from output of some backup scripts. When there is "End-of-tape detected" in directed output logs it should give alarm. First I would like to know if there is any better way to write... (5 Replies)
Discussion started by: EAGL€
5 Replies
5. Shell Programming and Scripting
Hi,
I have a file that looks like this - lets call it fileA
>hhm2
IIIIIIIIILLLLLLLMMMMMMMMMNNNNNNNNNNGGGGGGHHHHHHHH
>hhm4
OOOOOKKKKKKKKMMMMMHHHHHLLLLLLLLWWWWWWWWWWW
>hhm9
OOOOOOOIIIIIIIIIKKKKKKKKKMMMMMHHHHHHHHHHHLLLLLLLLLL
So the file is pretty straight forward. The name is indicated... (2 Replies)
Discussion started by: phil_heath
2 Replies
6. Shell Programming and Scripting
I have a main script with while loop having for loop inside. Again in for loop based on if condition few functions will be called. So when a function is called for certain condition it should come out from the main for loop and should continue with while loop.
Let me explain with example here:
I... (6 Replies)
Discussion started by: vpv0002
6 Replies
7. Shell Programming and Scripting
Dear Friends,
Here I need your guidance once again.
I have for loop which check all files in a folder for a particular string. If the string is found in a file it returns value other than 0 else returns 0 value in variable t2.
At times the string which we are looking for is in first file... (1 Reply)
Discussion started by: anushree.a
1 Replies
8. Shell Programming and Scripting
hi All,
cat login.list
server1 userid1
server2 userid2
server3 userid3
----------------------------------------
#SSHSCRIPT.ksh
FILE=login.list
while read vah vah_id
do
ssh $vah -l $vah_id "pwd"
done < "$FILE"
-----------------------------------------
When i... (2 Replies)
Discussion started by: raghur77
2 Replies
9. Shell Programming and Scripting
Here's my code -
for File in "${Files}"; do
uuencode "${File}" "$(basename ${File} 2>&-)" 2>&-;
done | mailx -s "subject" "a@b.c"
Now I want to know if there a way to *not* send an email if the "Files" variables turns out to be blank. Any suggestions?
Also, just to clarify, I... (4 Replies)
Discussion started by: nexional
4 Replies
10. Shell Programming and Scripting
Hi ,
I am trying to read a list of hosts from a config file and trying to get file list from that host. For this I have used one while loop.
cat "$ARCHIVE_CFG_FILE" | sed '/^$/d' | sed '/^#/d' | while read ARCHIVE_CFG
do
SOURCE_SERVER_NAME=`echo "$ARCHIVE_CFG" | awk -F '|' '{ print... (2 Replies)
Discussion started by: Anupam_Halder
2 Replies