---
title: "DB2: How to Call External Stored procedure"
description: "This post tells about very simple idea for DB2 developers about the concept of external stored procedures, how to create and how to run these stored procedures. The stored procedures can be written in any supported language."
url: https://srinimf.com/2016/11/10/how-to-run-external-stored-procedure-in-db2-precise-idea/
date: 2016-11-10
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2016/11/pexels-photo-4144099.jpeg?fit=1880%2C1255&ssl=1
categories: ["DB2 V10"]
tags: ["How to create external stored procedure in Db2"]
type: post
lang: en
---

# DB2: How to Call External Stored procedure

An external [stored procedure](https://srinimf.com/2025/09/10/pyspark-stored-procedure-alternative-explained-for-interview-prep/) is a procedure that is written in a host language and can contain SQL statements. The source code for external procedures is separate from the definition. Just a try [SQL Server with Stored procedures-Tables](https://goo.gl/iIXYvm), you can learn [how to](https://srinimf.com/2017/07/21/the-way-for-db2-stored-procedure-to-write-in-java/) apply for DB2.

**Example:**

The definition for external procedure. The “mymodule” stored procedure contains source code.

```
CREATE PROCEDURE SYSPROC.MYPROC(IN INT, OUT INT, OUT DECIMAL(7,2))
         LANGUAGE COBOL
         EXTERNAL NAME MYMODULE
         PARAMETER STYLE GENERAL
         WLM ENVIRONMENT PARTSA
         DYNAMIC RESULT SETS 1;
```

An external stored procedure is much like any other SQL application. It can include static or dynamic SQL statements, IFI calls, and DB2® commands that are issued through IFI.

**How to create external stored procedures**

You prepare external stored procedures as you would normally prepare application programs. You precompile, compile, and link-edit them. Then, you bind the DBRM into a package. 

LANGUAGE -This is mandatory clause used to specify the language interface convention to which the procedure body is written.

> All programs must be designed to run in the server’s environment. Assembler, C, COBOL, and PL/I programs must be designed to run in IBM®’s Language Environment®.

ASSEMBLE
The stored procedure is written in Assembler.
C
The stored procedure is written in C or C++.
COBOL
The stored procedure is written in COBOL, including the OO-COBOL language extensions.
JAVA
The stored procedure is written in Java and is executed in the Java Virtual Machine. When LANGUAGE JAVA is specified, the EXTERNAL NAME clause must be specified with a valid external-java-routine-nameand PARAMETER STYLE must be specified with JAVA. The procedure must be a public static method of the specified Java class.Do not specify LANGUAGE JAVA when DBINFO, PROGRAM TYPE MAIN, or RUN OPTIONS is specified.
PLI
The stored procedure is written in PL/I.
REXX
The stored procedure is written in REXX. Do not specify LANGUAGE REXX when PARAMETER STYLE SQL is in effect. When REXX is specified, the procedure must use PARAMETER STYLE GENERAL or GENERAL WITH NULLS.

Related Posts

- [Logic to call COBOL program from stored Procedure](https://srinimf.com/2013/03/22/db2-calling-cobolcjava-programs-from-stored-proc/)DateMarch 22, 2013
- [DB2-Stored Procedures – Examples](https://srinimf.com/2014/08/01/db2-stored-procedures/)DateAugust 1, 2014
- [How to write a COBOL Program in DB2 stored procedure](https://srinimf.com/2015/10/03/how-to-write-cobol-program-in-db2-stored-procedure-zos/)DateOctober 3, 2015

### 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%2F2016%2F11%2F10%2Fhow-to-run-external-stored-procedure-in-db2-precise-idea%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2016%2F11%2Fpexels-photo-4144099.jpeg%3Ffit%3D1200%252C801%26ssl%3D1&description=DB2%3A%20How%20to%20Call%20External%20Stored%20procedure)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2016/11/10/how-to-run-external-stored-procedure-in-db2-precise-idea/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2016/11/10/how-to-run-external-stored-procedure-in-db2-precise-idea/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2016/11/10/how-to-run-external-stored-procedure-in-db2-precise-idea/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2016/11/10/how-to-run-external-stored-procedure-in-db2-precise-idea/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20DB2%3A%20How%20to%20Call%20External%20Stored%20procedure&body=https%3A%2F%2Fsrinimf.com%2F2016%2F11%2F10%2Fhow-to-run-external-stored-procedure-in-db2-precise-idea%2F&share=email)
-

### Like this:

Like Loading…
