I work on db2 v 8.01 for AIX.
Is it possible to write dynamic sql query inside the script like in store procedure?
I would like to be able to define variables and execute dynamic queries from within the script - something like:
DECLARE stmt VARCHAR(1000);
DECLARE table_name VARCHAR(50);
SET table_name = 'DEPT_'||deptNumber||'_T';
SET stmt = 'DROP TABLE '||table_name;
PREPARE s1 FROM stmt;
EXECUTE s1;
I can do that from within the store procedure but not in the script.
Please help