IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Calling a Stored procedure in cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Pandora-Box

Global Moderator


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

PostPosted: Fri Apr 18, 2008 2:07 pm
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

Global Moderator


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

PostPosted: Fri Apr 18, 2008 2:53 pm
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
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: 792
Location: Chennai, India

PostPosted: Fri Apr 18, 2008 5:42 pm
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top