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: 1529
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: 641
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 execute APP if they are not ADDRESS T... italo_pm CLIST & REXX 3 Fri Aug 12, 2016 2:15 am
No new posts Creating a dynamic sort card in JCL u... ChitraChhabra DFSORT/ICETOOL 4 Wed Aug 03, 2016 6:15 pm
No new posts Execute multiple DB2 Load commands in... faizm DB2 4 Wed Aug 03, 2016 12:53 pm
No new posts Need help on SQL Dynamic WHERE Clause subratarec DB2 12 Sat Jul 16, 2016 3:11 pm
No new posts Need to create file with Dynamic Name... kapil27 JCL & VSAM 4 Wed May 25, 2016 9:45 am


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