I am doing db2 database migration to 10.5 from 9.5. After loading data. I'll need to reset all sequence value. I have this shell script produce a file after executing below SQL. But it gave me syntax error. I know it should be a constant value after key words "restart with", but we need to auto this process. Does anyone have idea how to achieve this ? Thanks lot !
db2 -x "select 'alter sequence ' || rtrim(a.SEQSCHE MA)||'.'||rtrim (a.SEQNAME) || ' restart with (select nextval for 'rtrim(a.SEQSCH EMA)||'.'||rtri m(a.SEQNAME from sysibm.sysdummy 1)' ||';' from SYSIBM.SYSSEQUE NCES a where SEQTYPE ='S' and SEQSCHEMA like 'DB2INST1%'" > seq_file.ddl
db2 -x "select 'alter sequence ' || rtrim(a.SEQSCHE MA)||'.'||rtrim (a.SEQNAME) || ' restart with (select nextval for 'rtrim(a.SEQSCH EMA)||'.'||rtri m(a.SEQNAME from sysibm.sysdummy 1)' ||';' from SYSIBM.SYSSEQUE NCES a where SEQTYPE ='S' and SEQSCHEMA like 'DB2INST1%'" > seq_file.ddl