0

I am using the below SQL statement to calculate the size of application group data table.

SELECT A.TABLE_NAME FROM ARSSEG A, ARSAG B WHERE A.AGID=B.AGID AND B.NAME='<application group name>' For EACH TABLE_NAME in query 1/, run "SELECT DOC_NAME, MAX(COMP_OFF+COMP_LEN) PLUS FROM <TABLE_NAME> GROUP BY DOC_NAME"

Now when I run this SQL statment in putty it throws an error

bash: syntax error near unexpected token `('

I have cross checket but i could not find where is the error. I need your help please help me out. thank you.

sai prudhvi
  • 41
  • 2
  • 4
  • 9

1 Answers1

0

Personally I would do this in a compound SQL statement that writes to a table. But if you want to do it from a command line, you could try e.g.

Still, try e.g.

db2 -x "SELECT 'SELECT DOC_NAME, MAX(COMP_OFF+COMP_LEN) PLUS FROM ' || A.TABLE_NAME || '  GROUP BY DOC_NAME ORDER BY A.TABLE_NAME;' FROM ARSSEG A, ARSAG B WHERE A.AGID=B.AGID AND B.NAME='<application group name>'" > tmp.sql
db2 -tf tmp.sql