Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

dynamic SQL - Prepare Execute

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: dynamic SQL - Prepare Execute
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    Post subject: Reply to: dynamic SQL - Prepare Execute
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

Moderator


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

PostPosted: Mon Jul 14, 2014 5:38 pm    Post subject:
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: 656
Location: Whitby, ON, Canada

PostPosted: Mon Jul 14, 2014 5:50 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts REXX - Dynamic file Creation d_sarlie CLIST & REXX 7 Tue Jun 27, 2017 7:30 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Dynamic split of files under groups sril.krishy DFSORT/ICETOOL 4 Mon Apr 17, 2017 1:09 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Dynamic array request/response contai... Suja.Sai CICS 2 Tue Jan 24, 2017 11:37 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us