Sorry, I was wrong.... Here is a example of what we did in creating a sql from an sql in a script. We do not use ". This may help.....
db2 "select 'db2 reorg table $OWNER.$TABLE Index $OWNER.' || name , ' use tempspace1 ' from sysibm.sysindexes where indextype = 'CLUS' and tbcreator = '$OWNER' and tbname = '$TABLE' union select 'db2 reorg table $OWNER.$TABLE Index ' || varchar( rtrim(creator),8) || '.' || name , ' use tempspace1 ' from sysibm.sysindexes where tbname = '$TABLE' and tbname not in (select tbname from sysibm.sysindexes where indextype = 'CLUS' and tbcreator = '$OWNER' and tbname = '$TABLE') and tbcreator = '$OWNER' and uniquerule = 'P'" >> $CMDLOG
Which creates a statement
db2 reorg table O.T Index O.I use tempspace1
So the single quote surround the characters I want in the statement else it will pull the value from the selected column.....
Also check where you end a line and continue it ......
I used the \" in other scripts so it would not translate it as a delimeter, which would not really help in your case.
could you please guide me is there anything needs to be modified in the shell script and why its not working the way I want when I run the above script...your help is greatly appreciated
create file like mkreorg.sql ( it is only for one table , if you want whole schema , remove tbname in where cluase)
put fooling statement in mkreorg.sql
connect to dbname ;
select ' reorg table '||trim(tbcreator)||'.'||ltrim(tbname) || ' index '|| rtrim(creator)||'.'||ltrim(name) ||' use tempspace1 ;'
where tbcreator = $OWNER and tbname = $TABLE
and ( indextype = 'CLUS' or uniquerule = 'P' );
run mkreorg.sql to genereate reorg scripts ( reorg.sql)