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
 

 

Calling a Stored procedure in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1537
Location: Andromeda Galaxy

PostPosted: Fri Apr 18, 2008 2:07 pm    Post subject: Calling a Stored procedure in cobol
Reply with quote

How to call a stored procedure in cobol ? It would be easier if anyone could explain me or give any tips right from creation of stored procedure step.

Thanks,
Prem
Back to top
View user's profile Send private message

Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1537
Location: Andromeda Galaxy

PostPosted: Fri Apr 18, 2008 2:53 pm    Post subject:
Reply with quote

Hi,

I would like to add more on that this is my store procedure code

Code:


CREATE PROCEDURE db2t.DISP(IN MGR CHAR(6),
                              IN ADM CHAR(3),
                              OUT RETURN_CODE INTEGER)
EXTERNAL NAME DISP
RESULT SETS 3
LANGUAGE SQL
COLLID db2t
WLM ENVIRONMENT DBDISP
RUN OPTIONS 'TRAP(OFF),RPTOPTS(OFF)'
P1: BEGIN
DECLARE SQLCODE INTEGER;
DECLARE CHECK_MGR_TMP INTEGER;
DECLARE CHECK_MGR_CSR CURSOR FOR
SELECT 1 FROM db2t.DEPT
WHERE MGRNO=MGR AND ADMDEPT = ADM
WITH UR;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
   SET RETURN_CODE = SQLCODE ;

CASE WHEN MGR IS NULL
 OR ADM IS NULL THEN
    SET RETURN_CODE = 999999;
 ELSE
    OPEN CHECK_MGR_CSR;
    FETCH CHECK_MGR_CSR INTO CHECK_MGR_TMP;
    IF SQLCODE = 100 THEN
       CLOSE CHECK_USER_CSR;
       SET RETURN_CODE = 999999;
       LEAVE P1;
    ELSE
       CLOSE CHECK_MGR_CSR;
       SET RETURN_CODE = 0;
       OPEN RS_CSR;
    END IF;
 END CASE ;
END P1



I need to write cobol to call this procedure.

Thanks,
Prem
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Fri Apr 18, 2008 5:22 pm    Post subject:
Reply with quote

Calling a stored procedure is same as calling a normal subroutine in COBOL.
Code:
CALL 'STORPROC' USING WS-LINKAGE


At the time of CALL, WS-LINKAGE should have the input values for the stored proc.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 788
Location: Chennai, India

PostPosted: Fri Apr 18, 2008 5:42 pm    Post subject:
Reply with quote

db2t.DISP(..., ..., ...,) is DB2 stored procedure.

So,
Code:
EXEC SQL
        CALL DB2T.DISP(..., ..., ...,)
END-EXEC.
Back to top
View user's profile Send private message
dharani.nagarajan

New User


Joined: 11 Nov 2010
Posts: 21
Location: India

PostPosted: Wed Jun 15, 2011 6:11 pm    Post subject: Reply to: Calling a Stored procedure in cobol
Reply with quote

Hi,

Is that always necessary to call a stored procedure within

EXEC SQL and
END-EXEC statements.


Can you please let me know.
I am trying to call a stored procedure from a COBOL-DB2 program using CALL statement and getting the error

LE COND CODE=CEE3201S / EXPECTED COMP CODE=S0C1

Can you please let me know.

Thanks,
Dharani
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Wed Jun 15, 2011 6:26 pm    Post subject:
Reply with quote

There are two redbooks that my help you:

DB2 for z/OS Stored Procedures: Through the CALL and Beyond

DB2 9 for z/OS Stored Procedures: Through the CALL and Beyond
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm
No new posts COBOL DB2 program - zIIP eligible vasanthz COBOL Programming 7 Wed May 31, 2017 5:12 am
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm


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