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 JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts Determine Region with max bandwidth f... seahawk789 COBOL Programming 3 Mon Feb 27, 2017 8:26 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm


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