-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathT_RPT_SQL.SQLRPGLE
More file actions
executable file
·238 lines (190 loc) · 5.79 KB
/
T_RPT_SQL.SQLRPGLE
File metadata and controls
executable file
·238 lines (190 loc) · 5.79 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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
/copy modules/qcopysrc,hspec_h
//*************************************************************************
// Program . . . . . T_RPT_SQL
//
// Created on . . . 09/17/2008
// by . . . Michael N. Wills
//
// Description . . . SQL Report Template
//
// To Compile:
// *> CRTSQLRPGI OBJ(&O/&ON) SRCFILE(&L/&F) SRCMBR(&N) -
// *> DBGVIEW(*SOURCE)
// *> DLTSPLF FILE(&N) SPLNBR(*LAST)
//
// CHANGE LOG:
// Date | Name | Description
// -----------------------------------------------------------------------
// | |
// | |
// | |
//*************************************************************************
// Files
F
// Printer/Display Files
FT_PRTF O E PRINTER oflind(*in40)
//*************************************************************************
// Named Constants
D
/copy modules/qcopysrc,status_h
// Named Indicators
D indicatorPtr S * Inz(%Addr(*IN))
D DS Based(IndicatorPtr)
D newPage 40 40N
// SQL Fields
D sqlStatement S 2048A varying
D SqlResult DS qualified
/copy modules/qcopysrc,sql_h
//*************************************************************************
// Misc Fields
D
//*************************************************************************
// External Program Procedures
// Internal Subprocedures
D Init PR
D Main PR
D PrintHeader PR
D BuildSqlStatement...
D PR
D OpenCursor PR 5A
D FetchNext PR 5A
D CloseCursor PR 5A
// External Subprocedures
///copy modules/qsrvsrc,string_h
//*************************************************************************
// Entry Parms
D T_RPT_SQL PR extpgm('T_RPT_SQL')
D T_RPT_SQL 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_RPT_SQL';
newPage = *on;
return;
/end-free
P Init E
P*--------------------------------------------------
P* Procedure name: Main
P* Purpose:
P* Returns:
P*--------------------------------------------------
P Main B
D Main PI
/free
BuildSqlStatement();
if (OpenCursor() = SQL_SUCCESS);
dow (FetchNext() = SQL_SUCCESS);
// TODO: INSERT CODE HERE
enddo;
endif;
CloseCursor();
return;
/end-free
P Main E
P*--------------------------------------------------
P* Procedure name: PrintHeader
P* Purpose:
P* Returns:
P*--------------------------------------------------
P PrintHeader B
D PrintHeader PI
/free
if (newPage);
write HEADER;
newPage = *off;
endif;
return;
/end-free
P PrintHeader E
P*--------------------------------------------------
P* Procedure name: BuildSqlStatement
P* Purpose:
P* Returns:
P*--------------------------------------------------
P BuildSqlStatement...
P B
D BuildSqlStatement...
D PI
/free
gSqlStatement = ' ';
return;
/end-free
P BuildSqlStatement...
P E
P*--------------------------------------------------
P* Procedure name: OpenCursor
P* Purpose:
P* Returns:
P*--------------------------------------------------
P OpenCursor B
D OpenCursor PI 5A
/free
exec sql
close c1;
exec sql
prepare sel from :gsqlstatement;
if sqlStt = SQL_SUCCESS;
exec sql
declare c1 cursor for sel;
exec sql
open c1;
endif;
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 :gresultds;
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