Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread Trigger a Job from code??
Mon, Jan 27 2025 1:24 AMPermanent Link

Ian Branch

Avatar

Hi Team,
Is there a way to trigger an EDB Job from Delphi code?

Regards & TIA,
Ian
Mon, Jan 27 2025 3:44 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Ian


Never done it but I'd say yes - but probably not in the way you think.

Look at select Name, Definition from configuration.jobs

If you select the job you want and copy its definition into a script, alter the first line to be a script header it should run.

Roy Lambert
Mon, Jan 27 2025 9:49 AMPermanent Link

Ian Branch

Avatar

Hi Roy,
The trouble with that as I see it is that the script is effectively run from the calling code rather than generic in the Server like a Job.
The consequence of that of course is that you need to allow for/handle long execution times..
That is not an issue with Jobs as they are executed totally within the Server.
Mon, Jan 27 2025 1:34 PMPermanent Link

Terry Swiers

From the EDB SQL docs...

"RESET JOB <Name>

Use this statement to reset a job. When a job is reset, the last run timestamp for the job is cleared. Subsequently, ElevateDB treats the job as never having been executed for scheduling purposes."

I've never tried it, but I assume that this will force the job to run almost immediately.
Tue, Jan 28 2025 3:20 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Terry


<<I assume that this will force the job to run almost immediately.>>

My interpretation is that the job will run on the next available "slot" so it would only be immediately if it was already in a "slot" eg (using one of Ian's)

FROM DATE '2018-10-06' TO DATE '2099-10-09'
MONTHLY ON THIRD SUN OF JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
BETWEEN TIME '08:00' AND TIME '08:45:00.999'

If he does "RESET JOB <Name> at 07:45 on a  third Sunday then it will run at 8:00. However, if he does it at 08:47 he'll have to wait until the next tthird Sunday.

I look forward to Ian reporting back on this.


Roy Lambert
Tue, Jan 28 2025 3:48 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Ian


Unless Terry's idea works I think you'll be stuck with this approach. If the job is right clicked in EDBManager there's a menu option - Run as script which basically does what I've suggested.

The other option I can think of is to clone the job but with a schedule that means run it now and then once it has run you have to figure out it has and  how to delete it.


Roy Lambert
Tue, Jan 28 2025 12:29 PMPermanent Link

Terry Swiers


> If he does "RESET JOB <Name> at 07:45 on a  third Sunday then it will run at 8:00. However, if he does it at 08:47 he'll have to wait until the next tthird Sunday.

You are absolutely correct.  I'm just so used to most all of my jobs being frequent enough that they would fire almost immediately that I forgot about jobs that are scheduled infrequently.
Tue, Jan 28 2025 1:43 PMPermanent Link

Ian Branch

Avatar

Roy, Terry,
Thanks or your input guys, appreciated.
I have given up on the idea.

Ian
Wed, Jan 29 2025 3:44 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Ian


Since I don't know why you wanted to do it I can't say how much effort would be appropriate. It would be easy to come up with a small chunk of code to replicate the job (I did for user defined functions between disk & memory databases) and set it to run once (say in 5 minutes time) and have a separate job to go through the jobs table once a  day deleting any that have been run.

Let me kniow if you want to explore that

Roy Lambert
Image