-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathT_SQLRET.SQLRPGLE
More file actions
executable file
·224 lines (188 loc) · 6.14 KB
/
T_SQLRET.SQLRPGLE
File metadata and controls
executable file
·224 lines (188 loc) · 6.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/copy modules/qcopysrc,hspec_h
//*************************************************************************
// Program . . . . . T_SQLRET
//
// Created on . . .
// by . . .
//
// Description . . . Template for returning an SQL result set.
//
// To Compile:
// *> CRTSQLRPGI OBJ(&O/&ON) SRCFILE(&L/QPGMSRC) SRCMBR(&N) -
// *> DBGVIEW(*SOURCE)
// *> DLTSPLF FILE(&N) SPLNBR(*LAST)
//
// CHANGE LOG:
// Date | Name | Description
// -----------------------------------------------------------------------
// | |
// | |
// | |
//*************************************************************************
// Files
F
//*************************************************************************
// Named Constants
D
/copy modules/qcopysrc,status_h
// Named Indicators
D indicatorPtr S * Inz(%Addr(*IN))
D DS Based(IndicatorPtr)
/copy modules/qcopysrc,sql_h
//*************************************************************************
// File Fields
D
//*************************************************************************
// Misc
D MessageList DS qualified
D Message 50A varying
D Date 10A
D WarningError N
D TerminalError N
D index S 3I 0
D rowCount S 10I 0
D pMessages DS likeds(MessageList) dim(100)
//*************************************************************************
// External Program Procedures
// Internal Subprocedures
D Init PR
D Main PR
D AddMessage PR
D message 50A varying const
D date D
D warningError N const
D terminalError N const
D OpenCursor PR 5A
D FetchNext PR 5A
D CloseCursor PR 5A
// External Subprocedures
/copy modules/qsrvsrc,cmd_h
//*************************************************************************
// Entry Parms
D T_SQLRET PR extpgm('T_SQLRET')
D T_SQLRET PI
//*************************************************************************
/free
Init();
Main();
*inlr = *on;
/end-free
P*--------------------------------------------------
P* Procedure name: Init
P* Purpose:
P* Returns:
P*--------------------------------------------------
P Init B
D Init PI
/free
exec sql
set option naming = *sys, commit = *none, usrprf = *user,
dynusrprf = *user, datfmt = *iso, closqlcsr = *endmod;
//pgm = 'T_SQLRET';
return;
/end-free
P Init E
P*--------------------------------------------------
P* Procedure name: Main
P* Purpose:
P* Returns:
P*--------------------------------------------------
P Main B
D Main PI
D i S 2P 0
/free
if (OpenCursor() = SQL_SUCCESS);
dow (FetchNext() = SQL_SUCCESS);
// TODO: Insert your code here
enddo;
endif;
CloseCursor();
exec sql
set result sets for return to client array
:pmessages for :rowcount rows;
return;
/end-free
P Main E
P*--------------------------------------------------
P* Procedure name: AddMessage
P* Purpose:
P* Returns:
P*--------------------------------------------------
P AddMessage B
D AddMessage PI
D message 50A varying const
D date D
D warningError N const
D terminalError N const
/free
index += 1;
pMessages(index).Message = message;
pMessages(index).Date = %char(date:*iso);
pMessages(index).TerminalError = terminalError;
pMessages(index).WarningError = warningError;
rowCount += 1;
return;
/end-free
P AddMessage E
P*--------------------------------------------------
P* Procedure name: OpenCursor
P* Purpose:
P* Returns:
P*--------------------------------------------------
P OpenCursor B
D OpenCursor PI 5A
D ssnNum S 9P 0
/free
exec sql
close c1;
exec sql
declare c1 cursor for
select *
from file;
exec sql
open c1;
return sqlStt;
/end-free
P OpenCursor E
P*--------------------------------------------------
P* Procedure name: FetchNext
P* Purpose:
P* Returns:
P*--------------------------------------------------
P FetchNext B
D FetchNext PI 5A
/free
exec sql
fetch c1 into :rec;
return sqlstt;
/end-free
P FetchNext E
P*--------------------------------------------------
P* Procedure name: CloseCusor
P* Purpose:
P* Returns:
P*--------------------------------------------------
P CloseCursor B
D CloseCursor PI 5A
/free
exec sql
close c1;
return sqlstt;
/end-free
P CloseCursor E
P*--------------------------------------------------
P* Procedure name: Template
P* Purpose:
P* Returns:
P*--------------------------------------------------
P*Template B
D*Template PI
*
*/free
*
*
*
* return;
*
*/end-free
P*Template E