× 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.



Crispin,

Sorry typo on my part, that should have said "But a trigger program
should never be ended with *LR = *ON anyway."

In one word, performance.

Reactivating the program, reintializing all the variables, and
reopening the files will kill the performance.

The REDBOOK - Stored Procedures, Triggers and User-Defined Functions
on DB2 UDB for iSeries says:
Performance Considerations (p435)
– Try to exit a trigger program the "soft" way. Avoid, if you can,
SETON LR in RPG, STOP
RUN in COBOL, and exit() in C. This allows you to leave some files
open and avoid the
overhead of opening them again when you get back into the trigger.
This technique is
broadly used in our trigger examples. Use a static variable to
determine whether the
file needs to be opened. In the C language, define the file pointer as
static and check
for the NULL value. In terms of application logic, if you open a file
to append record at
the end or for reading with random positioning, you can avoid closing it.

Since I happened to be doing some benchmarking anyway, I ran a quick quick.
An a 515 running v5r4, with no other users, and having a program
submitted to batch that updates every row of a 2.9 million record
table. (Table is journaled and update program commits every 1000
records, for why look for my next benchmark post :)

CPU Clock
no trigger 41 1:58
LR=*ON no files 260 7:30
LR=*ON 1 file 519 16:25
LR=*OFF 1 file 215 6:11

Charles


On Tue, Sep 9, 2008 at 11:25 AM, Crispin Bates <cbates@xxxxxxxxxxx> wrote:
Charles,

Why should trigger programs end with *INLR=*ON?

Thanks,

Crispin.

----- Original Message -----
From: "Charles Wilt" <charles.wilt@xxxxxxxxx>
To: "RPG programming on the AS400 / iSeries" <rpg400-l@xxxxxxxxxxxx>
Sent: Tuesday, September 09, 2008 10:59 AM
Subject: Re: Question about opening and closing files


No of course not.

But a trigger program should never be ended with *LR = *OFF anyway.

So alarm() might work.

Charles

On Tue, Sep 9, 2008 at 10:03 AM, Lim Hock-Chai
<Lim.Hock-Chai@xxxxxxxxxxxxxxx> wrote:
Are you saying that the alarm() api can actually wake up an in-active
program (ended with *inlr = *off)? That would be cool if this is true
:).




"Charles Wilt" <charles.wilt@xxxxxxxxx> wrote in message
news:<mailman.9454.1220926197.2545.rpg400-l@xxxxxxxxxxxx>...
Pretty big I'd guess....but it should be easy enough to test for
yourself..

(Maybe) a better idea:
Come up with a way to have the trigger program wake up after a few
minutes and close its files. This way, if your changing 100s of
records at a time, you'll only have to pay for one open/close.

Question is how to do the wake up?
First thought is to use alarm() API along with the appropriate signal
handling APIs.

BUT I don't know that trigger's play well with signals...don't know
they don't either. <grin>

Another possibly easier option:
Look at why is the file open an issue in the first place. Can you
make it not an issue? For instance, once place I've had trouble is
with a process that uses CLRPFM to clear a work file when that process
is called by an ODBC/JDBC client. Instead of a CLRPFM, I sometimes
will use an SQL DELETE. Or I'll change the program reading the file
to delete the record after it reads it. Consider adding
REUSEDLT(*YES) to the file.

HTH,
Charles





On Mon, Sep 8, 2008 at 8:47 PM, James Lampert
<jamesl@xxxxxxxxxxxxxxxxx> wrote:
How much overhead would you say is involved in making files *USROPN,
and
keeping them open only while actually performing I/O on them, as
opposed
to doing things the usual way?

We're thinking of doing this in a trigger program, in order to cut
back
on the number of file locks.

--
James H. H. Lampert
Touchtone Corporation

--
This is the RPG programming on the AS400 / iSeries (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.


--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing
list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.


--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.




--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.