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
 

 

Can DB2 commands be executed in a Batch JCL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Thu Sep 07, 2006 10:52 pm    Post subject: Can DB2 commands be executed in a Batch JCL
Reply with quote

Can DB2 commands be executed in a Batch JCL, Commands like -DIS etc. If so can someone post a example.
Back to top
View user's profile Send private message

ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Thu Sep 07, 2006 11:34 pm    Post subject:
Reply with quote

Since you can invoke any DB2 command under TSO, I assume you can issue it under BATCH TSO (For example: IKJEFT01 or from within REXX).

Have you ever noticed that whenever you run a batch DB2 program with the RUN command, you are actually running a DB2 command (DSN)?

O.
Back to top
View user's profile Send private message
MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Sat Sep 09, 2006 3:12 am    Post subject: Re: Can DB2 commands be executed in a Batch JCL
Reply with quote

I tried using IKJEFT01, and this did not work. SQL -104 is recieved.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Sat Sep 09, 2006 3:43 am    Post subject: Re: Can DB2 commands be executed in a Batch JCL
Reply with quote

Paste here complete step alongwith SQL Stmt you are running.

-104 denotes a syntax error.
Back to top
View user's profile Send private message
MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Mon Sep 11, 2006 8:08 pm    Post subject: Re: Can DB2 commands be executed in a Batch JCL
Reply with quote

Here is the information:

//DYNPROC PROC
//STEP01 EXEC PGM=IKJEFT01,DYNAMNBR=20,COND=(4,LT)
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSTSIN DD DUMMY
//SYSIN DD DUMMY
// PEND
//S001 EXEC DYNPROC
//SYSTSIN DD *
DSN SYSTEM(DBXX)
RUN PROGRAM(DSNTEP2) PLAN(DSNTEP2)
END
//SYSIN DD *
DISPLAY DATABASE(SGPADX01) SPACENAME(*)
/*


SYSPRINT MESSAGES:
***INPUT STATEMENT:
DISPLAY DATABASE(SGPADX01) SPACENAME(*)
SQLERROR ON DISPLAY COMMAND, PREPARE FUNCTION
RESULT OF SQL STATEMENT:
DSNT408I SQLCODE = -104, ERROR: ILLEGAL SYMBOL "(". SOME SYMBOLS THAT MIGHT BE LEGAL ARE: IS <HEXSTRING> <CHARSTRING>
<GRAPHSTRING>
DSNT418I SQLSTATE = 42601 SQLSTATE RETURN CODE
DSNT415I SQLERRP = DSNHPARS SQL PROCEDURE DETECTING ERROR
DSNT416I SQLERRD = 0 0 0 -1 17 0 SQL DIAGNOSTIC INFORMATION
DSNT416I SQLERRD = X'00000000' X'00000000' X'00000000' X'FFFFFFFF' X'00000011' X'00000000' SQL DIAGNOSTIC
INFORMATION

Also i tried with -DISPLAY and recieved same message.
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Mon Sep 11, 2006 9:28 pm    Post subject:
Reply with quote

DB2 commands always start with a dash ("-").

O.
Back to top
View user's profile Send private message
MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Mon Sep 11, 2006 10:11 pm    Post subject: Re: Can DB2 commands be executed in a Batch JCL
Reply with quote

Same result with -DISPLAY also

***INPUT STATEMENT:
-DISPLAY DATABASE(SGPADX01) SPACENAME(*)
SQLERROR ON -DISPLAY COMMAND, PREPARE FUNCTION
RESULT OF SQL STATEMENT:
DSNT408I SQLCODE = -104, ERROR: ILLEGAL SYMBOL "-". SOME SYMBOLS THAT MIGHT BE LEGAL ARE: ( END SET CALL DROP FREE HOLD
LOCK OPEN PARM ALTER BEGIN CLOSE
DSNT418I SQLSTATE = 42601 SQLSTATE RETURN CODE
DSNT415I SQLERRP = DSNHPARS SQL PROCEDURE DETECTING ERROR
DSNT416I SQLERRD = 0 0 0 -1 1 0 SQL DIAGNOSTIC INFORMATION
DSNT416I SQLERRD = X'00000000' X'00000000' X'00000000' X'FFFFFFFF' X'00000001' X'00000000' SQL DIAGNOSTIC
INFORMATION
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Mon Sep 11, 2006 11:27 pm    Post subject:
Reply with quote

No, no, no.... You already have a DB2 command in your code (RUN). Just remove the RUN line, and put the DISPLAY line instead. You don't need SYSIN (it's already DUMMYied before).

O.
Back to top
View user's profile Send private message
MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Tue Sep 12, 2006 12:05 am    Post subject: Re: Can DB2 commands be executed in a Batch JCL
Reply with quote

Thanks, Job worked.
Back to top
View user's profile Send private message
ajay_diaz
Warnings : 1

New User


Joined: 12 Sep 2005
Posts: 28

PostPosted: Fri Sep 15, 2006 7:10 am    Post subject: Re: Can DB2 commands be executed in a Batch JCL
Reply with quote

When I am trying the JCL below :

//STEP01 EXEC PGM=IKJEFT01,DYNAMNBR=20,COND=(4,LT)
//SYSIN DD DSN=R1LTPB.AJIT.QUERIES.TEMP,DISP=SHR
//SYSTSIN DD *
DSN SYSTEM(DB1A)
RUN PROGRAM(DSNTEP2) PLAN(DSNTEPSP) -
END
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSOUT DD SYSOUT=*
/*

I am getting follwong error message in SYSTSPRT

READY
DSN SYSTEM(DB1A)
IKJ56500I COMMAND DSN NOT FOUND
READY
RUN PROGRAM(DSNTEP2) PLAN(DSNTEPSP) END
IKJ56712I INVALID KEYWORD, PLAN(DSNTEPSP)
IKJ56712I INVALID KEYWORD, END
READY
END
Back to top
View user's profile Send private message
MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Fri Sep 15, 2006 8:12 pm    Post subject: Re: Can DB2 commands be executed in a Batch JCL
Reply with quote

Try changing PLAN(DSNTEPSP) to PLAN(DSNTEP2).

And here are some examples:

For what you are trying:

//STEP01 EXEC PGM=IKJEFT01,DYNAMNBR=20
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSTSIN DD *
DSN SYSTEM(DBxx)
RUN PROGRAM(DSNTEP2) PLAN(DSNTEP2)
END
//SYSIN DD *
Give insteam SQL or Modify to give DSN
/*

After help from Forum i used following for executing DB commands:
//STEP01 EXEC PGM=IKJEFT01,DYNAMNBR=20
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSTSIN DD *
DSN SYSTEM(DBxx)
-DISPLAY DATABASE(XXXXDB01) SPACENAM(*)
END
//SYSIN DD DUMMY

Also following can be used for executing SQL queries
Where output of SQL is in table download format (Raw data):


//STP0100 EXEC PGM=IKJEFT01,DYNAMNBR=20
//SYSREC00 DD DSN=Give dataset or write to sysout for query result
// DISP=(,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(1,1),RLSE),DCB=(MODEL.DSCB1,BLKSIZE=0)
//SYSPUNCH DD DUMMY
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSTSIN DD *
DSN SYSTEM(DBxx)
RUN PROGRAM(DSNTIAUL) PLAN(DSNTIAUL) PARMS('SQL')
END
/*
//SYSIN DD *
Select statement instream or modify to give dataset
/*
//*
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 Fileaid 2 commands instream work. In ... descann Compuware & Other Tools 2 Tue May 16, 2017 3:31 pm
No new posts HLIST Utility In Batch Virendra Shambharkar TSO/ISPF 4 Fri Apr 07, 2017 3:38 pm
No new posts Batch job tuning sgandhla Testing & Performance analysis 5 Fri Mar 24, 2017 9:41 pm
No new posts MIPS/CPU consumption reduction in Batch vishwakotin DFSORT/ICETOOL 4 Sat Mar 18, 2017 5:46 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm


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