View previous topic :: View next topic
|
Author |
Message |
erhema
New User
Joined: 07 Oct 2008 Posts: 23 Location: Chennai
|
|
|
|
Hi,
Is it possible to write dynamic SQL query to delete list of tables from a input file. (table names are dynamic here). I have seen examples for "delete from table1 where dept = ?" please advice.
Thanks in Advance. |
|
Back to top |
|
|
erhema
New User
Joined: 07 Oct 2008 Posts: 23 Location: Chennai
|
|
|
|
just to rephrase.
Is it possible to write dynamic SQL query to delete the entire table data from the list of table names from a input file?
Its not deleting the entire table. Its "to delete the table data" ( query : delete from tablename ) |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Hi erhema,
Is the table names always dynamic or is it restricted to some number? |
|
Back to top |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
One way to do this is to use DFSORT or some other tool to generate the SQL statements that you need. Then you can run the statements through DSNTEP2 or DSNTIAUL to perform the deletion. Something like:
Code: |
//GENSQL EXEC PGM=SORT
//*
//SORTIN DD *
owner.tblname_1
owner.tblname_2
//SORTOUT DD DISP=(,CATLG),DSN=xxxx.xxxxxx.xxxx.SQLDLET,
// UNIT=TSS1,SPACE=(TRK,(5,5),RLSE),BLKSIZE=0
//*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL BUILD=(C' DELETE FROM ',1,20,C';' )
/*
//SYSOUT DD SYSOUT=* |
|
|
Back to top |
|
|
|