midrange.com code scratchpad |
Name:
Example of RPG Stored Procedure With DS DIM()
|
Scriptlanguage:
Plain Text
|
Tabwidth:
4
|
Date:
04/17/2012 08:51:51 pm
|
IP:
Logged
|
|
Description:
For Michael Ryan's question posted here:
http://archive.midrange.com/rpg400-l/201204/msg00185.html
|
Code:
- H OPTION(*SRCSTMT)
- *
- * To compile:
- * CRTSQLRPGI OBJ(TESTPGM) DBGVIEW(*SOURCE)
- *
- * To install into database:
- * CREATE PROCEDURE TESTPROC()
- * LANGUAGE RPGLE
- * NOT DETERMINISTIC
- * CONTAINS SQL
- * EXTERNAL NAME TESTPGM
- * PROGRAM TYPE MAIN
- * PARAMETER STYLE GENERAL
- *
- * To run (as an SQL statement):
- * CALL TESTPROC
-
- D myReturnData...
- D DS qualified
- D Dim(100)
- D WOTran 16 0
- D WOINVTH 2 0
- D WOMA 1
-
- D x s 10i 0
- D myCount s 10i 0
-
- /free
- // just for a test, put something in
- // the returned data.
-
- for x = 1 to %elem(myReturnData);
- myReturnData(x).WOTran = x * 10;
- myReturnData(x).WOINVTH = x - 5;
- myReturnData(x).WOMA = 'X';
- endfor;
-
- myCount = %elem(myReturnData);
-
- exec SQL set result sets array :myReturnData
- for :myCount rows;
- *inlr = *on;
- /end-free
-
|
|
|