-
Notifications
You must be signed in to change notification settings - Fork 4
/
prodlist.rpgle
55 lines (44 loc) · 1.47 KB
/
prodlist.rpgle
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
<%@ language="SQLRPGLE" " %>
<%
ctl-opt copyright('System & Method (C), 2019');
ctl-opt decEdit('0.') datEdit(*YMD.) main(produceList);
ctl-opt bndDir('ICEBREAK');
exec sql set option commit=*NONE;
/* -----------------------------------------------------------------------------
CRTICEPGM STMF('/www/IceBreak-Samples/prodList.rpgle') SVRID(samples)
Send a product list to a client
http://sandbox.icebreak.org:60060/prodList.rpgle?search=silver
http://my_ibm_i:60060/prodList.rpgle?search=silver
\* -------------------------------------------------------------------- */
dcl-proc produceList;
dcl-s search varchar(256);
dcl-s comma varchar(1);
dcl-ds product extname ('ICPRODUCT') qualified end-ds;
// we are providing JSON for the client
setContentType('application/json;charset=utf-8');
// Get the data from the URL
search = '%' + qryStr('search') + '%';
exec sql declare c1 cursor for
select *
from icproduct
where lower(desc) like lower (:search);
exec sql open c1;
%>[<%
exec sql fetch c1 into :product;
dow sqlCode = 0;
%><%=comma %>
{
"prodkey": <% = %char(product.prodKey) %>,
"prodid": "<% = product.prodid %>",
"desc": "<% = product.desc %>",
"manuid": "<%= product.manuid %>",
"price": <%= %char(product.price) %>,
"stockcnt": <%= %char(product.stockcnt) %>,
"stockdate": "<%= %char(product.stockdate) %>"
}<%
comma = ',';
exec sql fetch c1 into :product;
enddo;
exec sql close c1;
%>]<%
end-proc;