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



Gad:
*
*Rifling through every active job on the system to determine whether a given program is "active" is probably not be the best way to go about this, whether using SQL procedures or by directly calling various APIs.

Is this a "batch" job running one of those programs that should not run more than one copy at the same time? If so, then a simple technique is to issue the ALCOBJ command to allocate the *PGM itself for *EXCL use ... then when the batch job ends, the lock is automatically released.

If it any of those programs might be invoked within an interactive job session, you can still attempt to allocate the object, with a short "time-out" interval and if the allocation fails, (meaning "already in use") you may want to display a nice message to tell the user:

XYZ is in use; please try again later

or some such ...

If you allocate the *PGM during an interactive job, hen you need to be sure to issue the corresponding DLCOBJ to ensure those locks are not (needlessly) held for the entire duration of the interactive job (until the user signs-off), e.g. as soon as the "exclusive use" is no longer needed.

_Design question
_In general, requiring only one person or job at a time to run a given program may indicate a "poor" or "bad" design.
_
_What are those programs doing that requires "exclusive" use of the program? What kind of a process is being performed that requires only one user or job at a time to be running a specific program? Is this some kind of "mass update" or "merge/purge" of some database file(s)? In that case, it might be more appropriate to lock the actual database file(s) in question ...

Hope this helps,

Mark S. Waterbury

> On 4/27/2017 2:43 AM, Gad Miron wrote:
Thanks Alan, Rob. That's what I was looking for.

Gad




from: Rob Berendt <rob@xxxxxxxxx>
subject: RE: Is a certain PGM/JOB running?

The link Alan gave is ideal for many of the DB2 for i Services. That list
will also tell you at which release, or ptf, the service either arrived,
and/or was enhanced.

There are also numerous other system catalog entries available at
https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/
db2/rbafzcatalog.htm

select count(*)
from table(active_job_info( JOB_NAME_FILTER => 'ADMIN')) x;

I have three jobs named ADMIN and several other ADMINx jobs in my QHTTPSVR
subsystem. This returned the number 3.
You could also code it as
select
case
when count(*) > 0 then '1'
else '0'
end as JobActive
from table(active_job_info( JOB_NAME_FILTER => 'ADMIN')) x;


This other service will NOT show a lock on a program just because it is in
a call stack.
select
system_object_schema, system_object_name,object_type, job_name
from qsys2.object_lock_info
where system_object_name = 'QZHBMAIN';




Rob Berendt
--
IBM Certified System Administrator - IBM i 6.1
Group Dekko
Dept 1600
Mail to: 2505 Dekko Drive
Garrett, IN 46738
Ship to: Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com





From: Alan Shore <ashore@xxxxxxxx>
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Date: 04/26/2017 07:35 AM
Subject: RE: Is a certain PGM/JOB running?
Sent by: "MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxx>



Hi Gad
Have a look here
I was given this just recently and haven't had time to go through it much


http://ibm.biz/DB2foriServices


Alan Shore
E-mail : ASHORE@xxxxxxxx
Phone [O] : (631) 200-5019
Phone [C] : (631) 880-8640
'If you're going through hell, keep going.'
Winston Churchill

-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Gad
Miron
Sent: Wednesday, April 26, 2017 6:28 AM
To: midrange-l@xxxxxxxxxxxx
Subject: Fwd: Is a certain PGM/JOB running?

Hello pundits

There are some jobs/pgms here that need to verify they are not already
executing.
(if they are, then please wait an try again or exit gracefully) Do the new
SQL Tables/Views introduced lately enable such a check?

TIA
Gad

PS
Back in the (very) old days of S/36 there was a IF-ACTIVE OCL (me think)



As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.