---
title: "How to Access Stored procedure in CICS popular example to invoke it"
description: "Given here beautiful example to call stored procedure from CICS programs. This is a solution and ready to use code for your CICS programs using DB2."
url: https://srinimf.com/2013/03/25/db2-stored-proc-from-cics-how/
date: 2013-03-25
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2013/03/stored-procedure-in-cics.jpg?fit=1200%2C700&ssl=1
categories: ["CICS Tips"]
tags: ["CICS tips and Tricks"]
type: post
lang: en
---

# How to Access Stored procedure in CICS popular example to invoke it

Yes, you can access Db2 stored procedure from CICS. CICS transaction manager comes with DB2 attachment facility.This is the reason CICS can access [DB2 stored procedure](https://srinimf.com/2013/03/24/db2-how-to-access-cics-from-db2-stored-proc/) from CICS.

---

[![Tweets](https://i0.wp.com/srinimf.com/wp-content/uploads/2013/03/tweets.png?resize=420%2C361&ssl=1)](https://i0.wp.com/srinimf.com/wp-content/uploads/2013/03/tweets.png?ssl=1)

**Every CICS region can access only one DB2 sub-system.**

- Stored procedures are accessed from CICS programs by issuing SQL CALL statements
- A CALL statement that references a stored procedure must be bracketed between EXEC SQL and the statement terminator appropriate for the host language
- For COBOL programs, the statement terminator is END-EXEC

**An example [to CALL](https://srinimf.com/2016/11/10/how-to-run-external-stored-procedure-in-db2-precise-idea/) stored proc in CICS**

Related[3 Top Methods to Access COBOL Program from Web](https://srinimf.com/2015/11/10/3-top-methods-to-keep-mainframecobol-programs-web-enabled/)

```
EXEC SQL
      CALL EMPRSETC(
                    :PDEPTNO
                    ,:PDEPTNAME
                    ,:PSQLCODE
                    ,:PSQLSTATE
                    ,:PSQLERRMC
                   )
 END-EXEC.
```

Note: The CICS application program must include [logic to](https://srinimf.com/2013/03/22/db2-calling-cobolcjava-programs-from-stored-proc/) set the host variables prior to executing the CALL, and must include logic to handle any error conditions returned by the [stored procedure](https://srinimf.com/2015/08/17/calling-stored-procedure-in-db2-a-best-example/).

These two logic components are no different than what is required of a batch program written in the same host language. Refer more in the [link](http://www.redbooks.ibm.com/redbooks/pdfs/sg247604.pdf)from IBM.

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2013%2F03%2F25%2Fdb2-stored-proc-from-cics-how%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2013%2F03%2Fstored-procedure-in-cics.jpg%3Ffit%3D1200%252C700%26ssl%3D1&description=How%20to%20Access%20Stored%20procedure%20in%20CICS%20popular%20example%20to%20invoke%20it)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2013/03/25/db2-stored-proc-from-cics-how/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2013/03/25/db2-stored-proc-from-cics-how/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2013/03/25/db2-stored-proc-from-cics-how/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2013/03/25/db2-stored-proc-from-cics-how/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20How%20to%20Access%20Stored%20procedure%20in%20CICS%20popular%20example%20to%20invoke%20it&body=https%3A%2F%2Fsrinimf.com%2F2013%2F03%2F25%2Fdb2-stored-proc-from-cics-how%2F&share=email)
-

### Like this:

Like Loading…
