0
votes

I am executing below command on Shell bash after connecting to the database the textfile below has table names in the DB2 database like

TABLE1
TABLE2
..
TABLEN

for tablenam in $(cat textfile)
do
 db2 'EXPORT TO $PPL_IXFDRV/PREBKP/tablenam.IXF OF~
  IXF MESSAGES /dev/null~
  SELECT * FROM $SCHEMA.tablenam'
done

When I run this I get below error

SQL3022N An SQL error "-204" occurred while processing the SELECT string in
the Action String parameter.

I have tried the above command with single quote like below

for tablenam in $(cat textfile)
do
 db2 EXPORT TO $PPL_IXFDRV/PREBKP/tablenam.IXF OF~
  IXF MESSAGES /dev/null~
  SELECT \* FROM $SCHEMA.tablenam
done

This also gives me the same result

What I am trying to do here is unload in IXF format DB2 tables present in the list "textfile" in the Database substituting tablenam in the repeated commands for db2 EXPORT

1
Clearly Db2 cannot find the table you're trying to export. Use the -v switch with db2 to echo the actual command being executed; you'll probably see where the problem is.mustaccio

1 Answers

0
votes

Try this:

for tablenam in $(cat textfile)
do
 db2 "EXPORT TO ${PPL_IXFDRV}/PREBKP/${tablenam}.IXF OF
  IXF 
  SELECT * FROM ${SCHEMA}.${tablenam}"
done