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: 1534
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: 1534
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: 6966
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 SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Submit job from Cobol with input data abdulrafi COBOL Programming 4 Wed Feb 01, 2017 12:41 pm


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