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

Running SQL query using JCL


IBM Mainframe Forums -> DB2
Post new topic   This topic is locked: you cannot edit posts or make replies.
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
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
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
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
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: 631
Location: Wisconsin

PostPosted: Fri Jan 11, 2008 6:17 pm
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
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: 631
Location: Wisconsin

PostPosted: Fri Jan 11, 2008 7:21 pm
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. All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts DB2 Query to get the count of Unique ... DB2 2
No new posts Need help with ADABAS query (COBOL-AD... All Other Mainframe Topics 1
No new posts Running REXX through JOB CLIST & REXX 13
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:


Back to Top