Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts Running an REXX EXEC implicitly sho7hills CLIST & REXX 3 Thu Apr 20, 2017 8:14 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us