× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I am currently working on a service program handling data access, in its
most simplistic form it has gets, returning data structures, and I am
now working on the Put side of things.

I am thinking along the lines of the service program first sending *diag
messages to the caller, followed by an *escape denoting a hard error.

Something along the lines of:
SRVPGM_CustomerIsValid - procedure
if Customer.Name = *blanks
QMHSNDPM - Name is invalid - *diag.
IsError = *on
endif
etc...

if IsError
QMHSNDPM - Record is invalid - *escape
endif
SRVPGM_CustomerIsValid - end procedure

I know this works, handling the errors and relaying them to the display
is still to be worked on (1), and performs the task well.

I also know I can add tests to the DB using referential integrity and
also additional trigger-before testing and even something as simple as
duplicate key checking.

From what I can make out, correct me if I'm wrong, any testing in the DB
is done one by one till either it passes all the tests (and performs the
record update/add), or if an error is raised then any following, yet to
be checked, tests are not performed - it stops dead.

Also, again correct me if I'm wrong, if a file has 2 or more RI's and
none of them are valid then only the first fail is logged, the
outstanding RI's are not checked.

From looking at ODBC (and I assume embedded SQL and CLI SQL) not only is
an error/current status returned but also its possible to return a
varying list of diagnostic messages.

Now my questions are:
1) if I were to move the validation into the DB as a
before-record-trigger (or some other method) could I use the same "idea"
of sending *diags followed by an exception, and if I can does this
information get sent to the ILE performing the update so I can do
something along the lines of:
monitor
write Record
on-error
get exception error (QMHRCVM)
if exception = my exception
get all *diags (QMHRCVM)
display/condition fields on screen according to messages
else
handle DB exceptions such as "duplicate key" or "RI" etc.
endif
endmon

2) if the above is valid, does the same hold true if I use embedded SQL,
can I receive the exception and the diags and handle them.

3) again if the above is valid, does it also hold true of CLI SQL on the
i.

4) finally, are the diags and exception available to an application that
doesn't reside on the i (pc-app) or is native but not ILE (say via pase
or the like) - such as a ODBC - Java - C#

The main reason for asking the above is that while I know I can handle
things in a "normal" ILE/RPG/*SRVPGM validation program I don't want to
back myself into a corner and find that the next stage of ideas to test
just won't work. Obviously I'm designing with an eye to moving onto to
the next logical progression, but if that progression is not going to
work then there seems little point in designing with a forward view
(which won't work) and it would be better to design for "this works
really well in this scenario" and look at something totally different
for the next stage of DB constraints and tests.

Has anyone else done something similar?

Thanks in advance
Jon.


(1) I had initially thought about somehow passing back an array with
indicators denoting the field in error, but while this would work in a
simple all ILE program it fails if at some point the code is put into
the DB.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.