ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Creating a function as a wrapper around an RPG program

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating a function as a wrapper around an RPG program

    A vendor has supplied an RPG program that has 3 input parameters and 2 output parameters. I'm wondering if and how it can be called from SQL.

    The RPG *entry plist looks like this:

    c *entry plist
    c parm in_company
    c parm in_location
    c parm in_item_no
    c parm out_qty_on_hand
    c parm out_qty_committed

    Can I create a function that ​wraps this rpg program and then use the function in an sql select statement?

  • #2
    A program can only be registered as a Stored Procedure, and then can be called with the SQL CALL command.
    A UDF can only return a single value and all parameters are input only, so only RPG Functions can be registered as UDFs
    A UDTF which can return a table (i.e. a predefined number of columns and *Zero to N rows, can be written in RPG but needs a special syntax, because the RPG-Program to be registered gets call via callback processing at least 3 times (Open Call, Fetch Call, Close Call). The FETCH call can occur multiple times.

    Comment

    Working...
    X