Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 11 total
Thread Start a Server Job from an Application?
Sat, Mar 21 2020 8:21 PMPermanent Link

Ian Branch

Avatar

Hi Team,
My edbsrvr has a Backup Job that normally triggers around 0430.
I want to be able to trigger it from an App at other times if possible.
Can I ?  If so, how please?
Regards,
Ian
Mon, Mar 23 2020 2:00 PMPermanent Link

Terry Swiers

Hi Ian,

> My edbsrvr has a Backup Job that normally triggers around 0430. I want to be able to trigger it from an App at other times if possible.  Can I ?  If so, how please?

Move the backup job to a procedure, then rewrite the backup job to call the procedure.  This gives you the ability to then call the same procedure from the application as well on demand.
Mon, Mar 23 2020 8:59 PMPermanent Link

Ian Branch

Avatar

Hi Terry,
Sounds like a plan.  I haven't done a procedure before.
I created the following..
{sql}
CREATE PROCEDURE "WorkflowBackup" ()
BEGIN
BACKUP DATABASE "DBiWorkflow" AS "DBiWorkflow-Server Backup-' + CAST(CURRENT_DATE AS VARCHAR(10)) + '" TO STORE "Backups" COMPRESSION 9 INCLUDE CATALOG;
END
VERSION 1.00
{sql}
But I get the following error.."ElevateDB Error #700 An error was found in the statement at line 3 and column 8 (Expected : but instead found DATABASE)"
I know this works as a Job, why doesn't it work for a procedure?

Ian
Tue, Mar 24 2020 1:03 AMPermanent Link

Terry Swiers


> I know this works as a Job, why doesn't it work for a procedure?

Open up EDB Explorer, right click on the job, and select Execute Job as a Script.   This will give you what you need for the body of the procedure.

Terry
Tue, Mar 24 2020 4:01 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Ian


If you want to run it in your application there is another cheat way of doing it.

Have a look in EDBManager at the result from the following

select * from configuration.jobs

One column is Definition which is exactly what it says. You should be able to create a query in your application to read this (eg select Definition from configuration.jobs where Name = 'Ians Job')  then you put the data from Definition as the sql for a query and simply run it.


Roy Lambert
Tue, Mar 24 2020 4:45 AMPermanent Link

Ian Branch

Avatar

Roy, Terry,
Thank you for your inputs.
So, it appears that the Procedure prefers the  Script style.
{sql}
BEGIN
EXECUTE IMMEDIATE 'BACKUP DATABASE "DBiWorkflow" AS "DBiWorkflow-Server Backup-' + CAST(CURRENT_DATE AS VARCHAR(10)) + '" TO STORE "Backups" COMPRESSION 9 INCLUDE CATALOG';
EXECUTE IMMEDIATE 'DROP DATABASE"DBiWorkflow"';
END
{sql}
This was accepted when creating the procedure.
If I now attempt to execute the procedure in edbmgr I get a 'Cannot lock the databse DBiWorkflow for exclusive access" @ Line 4, column 19, error message.  There is nothing at Line 4 column 19.

Ian
Tue, Mar 24 2020 4:48 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Ian,

BEGIN
  EXECUTE IMMEDIATE 'BACKUP DATABASE "DBiWorkflow" ...

--
Fernando Dias
[Team Elevate]
Tue, Mar 24 2020 4:53 AMPermanent Link

Ian Branch

Avatar

Ahhh.  So it automatically inserts SCRIPT at the start.
Hence Line 4 is in fact "EXECUTE IMMEDIATE 'DROP DATABASE"DBiWorkflow"';"

Removing this line makes it all work.

Thank you.

Ian
Tue, Mar 24 2020 5:06 AMPermanent Link

Ian Branch

Avatar

OK.  I am missing a syntax here.
The Procedure runs fine.
I have found out how to call the procedure from Delphi.
What I can't figure/find the syntax, is how to call the procedure from inside the Job. Frown
Help.

Regards & TIA,
Ian
Tue, Mar 24 2020 5:13 AMPermanent Link

Ian Branch

Avatar

Ahhh Ha!
{code}
SCRIPT
BEGIN
CALL WorkflowBackup;
END
{code}
Page 1 of 2Next Page »
Jump to Page:  1 2
Image