MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Stored proc - thru JCL?

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
MFdigger
Beginner


Joined: 09 Sep 2005
Posts: 124
Topics: 52
Location: Chicago

PostPosted: Thu Feb 19, 2009 1:58 pm    Post subject: Stored proc - thru JCL? Reply with quote

Hi All,

Can I execute a stored procedure thru the JCL? Please clarify

Thank you
_________________
Tx
Digger
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Thu Feb 19, 2009 2:32 pm    Post subject: Reply with quote

I suppose that depends. If your stored proc has no SQL, in theory, I suppose you could code a JCL EXEC to execute it. If there's any SQL, you need to establish a DB2 connection somehow first, usually IKJEFTxx.
Back to top
View user's profile Send private message
rk_pulikonda
Beginner


Joined: 27 May 2003
Posts: 22
Topics: 2
Location: India

PostPosted: Thu Feb 19, 2009 11:43 pm    Post subject: Reply with quote

Do you want to execute the Stored Procedure directly or through another program ?

If it is through another program we can call.

Here is an exmple.

1. Working section Declaration.

01 PGM-LOC1 USAGE SQL
TYPE IS RESULT-SET-LOCATOR VARYING.

2. Call the Stored procedure

EXEC SQL
CALL :STOR-PROC (:PARM1,
:PARM2,
:PARM3,
:PARM4
)
END-EXEC

3. Using ASSOCIATE command point the locator to the result set.

EXEC SQL
ASSOCIATE LOCATOR (:PGM-LOC1)
WITH PROCEDURE :STOR-PROC
END-EXEC

4. Using ALLOCATE command attach the locator to the cursor.

EXEC SQL
ALLOCATE PGM_CSR1 CURSOR
FOR RESULT SET :PGM-LOC1
END-EXEC

5. The result set is attached to cursor PGM_CSR1 .
_________________
Thanks
-Ram
Back to top
View user's profile Send private message
MFdigger
Beginner


Joined: 09 Sep 2005
Posts: 124
Topics: 52
Location: Chicago

PostPosted: Fri Feb 20, 2009 8:42 am    Post subject: Reply with quote

Hi Ram,

Thank you very much for the details, I never know that there is some thing called ALLOCATE command and we can use the STORED PROCEDURE as you mentioned above.

Can it be possible to run the stored procedure directly from the JCL, just like we execute any other program?

Thank you Rolling Eyes
_________________
Tx
Digger
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Fri Feb 20, 2009 10:55 am    Post subject: Reply with quote

MFdigger

Set it up and try it in your test environment. See what happens. But think about this. If you're executing SQL statements, won't you need a connection to DB2? Do you get a connection to DB2 just by coding EXEC PGM=<pgm> in JCL? How do you normally establish a connection to DB2? If your stored proc returns a results set, what is going to receive it? The job?

Stored procs are integrated into the DB. They're designed to be called and executed within the DB. You can get creative and try to execute them outside the DB, but you need to have some really good reasons to do that. And if you're executing the stored procs outside the DB engine, why do you need a stored proc in the first place?
Back to top
View user's profile Send private message
rk_pulikonda
Beginner


Joined: 27 May 2003
Posts: 22
Topics: 2
Location: India

PostPosted: Fri Feb 20, 2009 6:44 pm    Post subject: Reply with quote

MFdigger

One small question ?

What is the difference between stored procedure written in COBOL accessing DB2 tables and normal COBOL program accessing DB2 tables..?

Just check the below link for any help.
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNITH11/2.3.8?SHELF=DSNSHHA1&DT=20010710161352
_________________
Thanks
-Ram
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group