On Mon, 31 Dec 2018 at 07:56, Steve Richter <stephenrichter@xxxxxxxxx> wrote:
just for a contrary point of view Booth, this is pointless. Being that we
have SQL procedures, functions and table functions, there is not much use
for ILE procedures and service programs. Instead of writing reusable
modules of code as an ILE procedure, write it as an SQL function or
procedure. The SQL routine can have a long name, just like an ILE
procedure. And it can be called from anywhere on the system, especially
and most importantly, from SQL itself. This reuse of code comes without
the cost of the complexity of the bind process and the dreaded signature
violation.
My experience is a bit different, and perhaps there is value in
sharing that difference. When I'm asked to give the web team something
(say, customer sales history) I write them a Db2 stored procedure that
returns a result set. I then CREATE PROCEDURE LANGUAGE RPG and tell
Db2 about it. Now my code can be called from SQL, be debugged by
SEP/RDi, and even be consumed directly by other RPG programs. It also
has the very distinct advantage that it can directly invoke existing
sub-procedures / programs, just like any other RPG program. I can
restrict web access to the tables via standard IBM i security, and
grant access to the program with USRPRF(*OWNER) so that the /program/
can interact with the database but the web code cannot. This whole
process very much fits my 'RPG brain'.
With respect to the dreaded signature violation, I can only guess what
that is like. I myself have not experienced on of those in a long,
long-o time. This thread (among others) describes my approach:
https://archive.midrange.com/rpg400-l/201302/msg00238.html
This somewhat recent thread has useful advice for avoiding signature
violations:
https://archive.midrange.com/rpg400-l/201709/msg00125.html
What makes my experience different to yours is that I've been creating
and using service programs since V3R6: it's extremely familiar ground
for me. It's an interesting and very useful question to ask if I had
no service programs at all in my code base here in 2018, whether I'd
start writing them solely for the purpose of making Db2 data available
to the web. Steve's advice isn't wrong: CREATE PROCEDURE LANGUAGE SQL
is wicked powerful. If you don't already use sub-procedures, or a
bunch of CALL opcodes, to invoke other RPG programs from within RPG,
then I might have a long think about what my goals are. If you
personally want to focus on the webby bits, and service programs are
Just One More Thing you don't want to learn right now, then by all
means give LANGUAGE SQL a whirl.
If CREATE PROCEDURE LANGUAGE SQL is also a hurdle you need to climb,
I'm not sure what advice to offer a new web programmer except that I'm
an RPG programmer, so that's where my 'natural' bias lies.
--buck
As an Amazon Associate we earn from qualifying purchases.