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
 

 

Running SQL query using JCL

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
raak

Active User


Joined: 23 May 2006
Posts: 166
Location: chennai

PostPosted: Fri Jan 11, 2008 12:54 pm    Post subject: Running SQL query using JCL
Reply with quote

I have an SQL query and I want to run it using JCL..
I dont want to write a cobol program and then use a JCL to execute that..
Can a simple JCL submit a query??

The idea is to submit the query so that it should run in the background. Is there any way out???
Back to top
View user's profile Send private message

dinucpaul

New User


Joined: 11 Jan 2008
Posts: 3
Location: Bangalore

PostPosted: Fri Jan 11, 2008 1:23 pm    Post subject: Reply to: Running SQL query using JCL
Reply with quote

yes , you can do it using DSNTEP2 pgm in your JCL. plz find the exp

//STEP01 EXEC DB2CPROC,
// DB2SYS=Db2n
//SYSTSIN DD *
RUN PROGRAM(DSNTEP2) PLAN(DSNTEP2)
END
/*
//SYSIN DD *


select * from table1
Back to top
View user's profile Send private message
raak

Active User


Joined: 23 May 2006
Posts: 166
Location: chennai

PostPosted: Fri Jan 11, 2008 2:36 pm    Post subject:
Reply with quote

what is this DB2PROC and DSNTEP2.

I am getting a JEM message as " procedure DB2PROC not found".

Is that shop specific??
Back to top
View user's profile Send private message
raak

Active User


Joined: 23 May 2006
Posts: 166
Location: chennai

PostPosted: Fri Jan 11, 2008 5:46 pm    Post subject: Reply to: Running SQL query using JCL
Reply with quote

I tried to use the Unload utility to do this.

But my SQL contains a JOIN and the the columns are given as Tablename.column in the SELECT statement.

So the Unload JCL is abending saying that "." symbol is invalid.

Is there any other way I can do it??
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Fri Jan 11, 2008 6:17 pm    Post subject:
Reply with quote

There is a simple way to do this from a JCL step. I'll post it when I get to work and get on a system.
Back to top
View user's profile Send private message
raak

Active User


Joined: 23 May 2006
Posts: 166
Location: chennai

PostPosted: Fri Jan 11, 2008 6:30 pm    Post subject:
Reply with quote

k stodolas... waiting 4 it..... icon_rolleyes.gif
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Fri Jan 11, 2008 7:21 pm    Post subject:
Reply with quote

Code:

//JS02 EXEC DSNTEP2,DB2=DB2T,COND=(4,LT)                               
//DYNSQL.SYSPRINT DD SYSOUT=*                                           
//SYSIN    DD *                                                         
  INSERT INTO OWNER.TABLE (COL1, COL2)           
    SELECT MAX(COLA), COLB
    FROM  OWNER.TABLE2
    GROUP BY COLB;                                                 
                                                                       
  COMMIT;                                                               
/*                                                                     
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies.    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 Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


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