Recycling RPG as Stored Procedures

Recycling RPG as Stored Procedures

In today’s IT shops, application integration across multiple platforms is commonplace. Even the if applications that run the bulk of your business are written in RPG, there are probably requirements from non-RPG and non-IBM i applications to get access to some of your business functions. One of the most efficient ways to provide that access is by providing a stored procedure that can be called from any SQL platform. Fortunately, it’s not only efficient at run time; it’s also very easy to do. In this article, we’ll take a look at the basics of turning an RPG program into a stored procedure.

A stored procedure is simply a program that can be called from SQL. Since SQL is a database language, that means that for us, the call comes into the system via DB2. There are two kinds of stored procedures on IBM i: External and SQL. SQL stored procedures are written completely in an SQL procedure language while external stored procedures are written in a high-level language such as RPG. We’ll concentrate on external stored procedures here since it provides a good way to recycle some of your existing logic or leverage your RPG skills by writing some logic for these other types of applications without needing to learn a new language or new programming techniques. If you can write an RPG (or COBOL or CL) program that communicates via passed parameters, you can write a stored procedure.

Even though stored procedures are called using SQL, there’s no requirement that the RPG program called uses SQL (unless you decide to use more advanced stored procedure features such as returning result sets). You may use embedded SQL, of course, but you may also use “native” RPG CHAIN, READ or UPDATE operations.

Jon Paris is a technical editor with IBM Systems Magazine and co-owner of Partner400.

Susan Gantner is a technical editor with IBM Systems Magazine and co-owner of Partner400.

comments powered by Disqus



2019 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

New and Improved XML-INTO

Namespace support makes the opcode a viable option

Authenticating on the Web

The finer points of OpenRPGUI, Part 1

The Microphone is Open

Add your voice: Should IBM i include open-source RPG tools?

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters