IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

dynamic SQL - Prepare Execute


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
erhema

New User


Joined: 07 Oct 2008
Posts: 23
Location: Chennai

PostPosted: Mon Jul 14, 2014 1:07 pm
Reply with quote

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
View user's profile Send private message
erhema

New User


Joined: 07 Oct 2008
Posts: 23
Location: Chennai

PostPosted: Mon Jul 14, 2014 5:28 pm
Reply with quote

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
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Mon Jul 14, 2014 5:38 pm
Reply with quote

Hi erhema,
Is the table names always dynamic or is it restricted to some number?
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Mon Jul 14, 2014 5:50 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Execute secondary panel of sdsf with ... CLIST & REXX 1
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts Fetch data from programs execute (dat... DB2 3
No new posts JCL Dynamic System Symbols JCL & VSAM 3
This topic is locked: you cannot edit posts or make replies. How To Write, Compile and Execute Cob... COBOL Programming 5
Search our Forums:

Back to Top