Re: pg_agent jobs

From: Giovanni Biscontini <biscontini(dot)g(at)es2000(dot)it>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: pg_agent jobs
Date: 2023-10-02 07:50:24
Message-ID: CAOM+UfWG8Qbi60Fk218T+p0fnwHFC8c25tq0Tg+BoQOzMyXZ9w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi, Yes I know I've to use the "on error" property, but the cue is to raise
an error if query has a false result: for my knowledges the only way to do
it is to "create or replace" a PL/pgSQL procedure that than uses a "RAISE
ERROR" inside, but isn't there a more "SQL only way to do it?
thanks in advance, G

Il giorno ven 29 set 2023 alle ore 18:15 Adrian Klaver <
adrian(dot)klaver(at)aklaver(dot)com> ha scritto:

> On 9/29/23 08:55, Giovanni Biscontini wrote:
> > Hello all members, here's my question: db version 14.5
> > we have to create a pg_agent job with 2 steps:
> > 1_step execute query: if query result is true or find > 0 records then
> > process next step, else it stops executing job
> > 2_step execute batch command
> > we tried to seta as 1_step the query:
> > SELECT EXISTS (SELECT * FROM mytable WHERE someconditions)
> > but even if it returns false 2_step is always executed.
> > Need some help, thanks in advance, Giovanni
>
> The only thing I could see here:
>
> https://www.pgadmin.org/docs/pgadmin4/development/pgagent_jobs.html
>
> that might work is:
>
> "
> Use the On error drop-down to specify the behavior of pgAgent if it
> encounters an error while executing the step. Select from:
>
> Fail - Stop the job if you encounter an error while processing this
> step.
>
> Success - Mark the step as completing successfully, and continue.
>
> Ignore - Ignore the error, and continue.
> "
>
> So in the first step induce an error if the conditions are not met.
>
>
> > --
> >
> > best regards
> >
> >
> >
>
> --
> Adrian Klaver
> adrian(dot)klaver(at)aklaver(dot)com
>
>

--

*Cordiali saluti*

*Dott. Giovanni Biscontini*

Software Developer & Database Architect

Strada Ponte Alto Sud, 74
41123 Modena (MO)
Tel.: 059.452094
Cell: 3938282174
Mail: biscontini(dot)g(at)es2000(dot)it <verrini(dot)e(at)es2000(dot)it>
Web: https://www.es2000.it <http://www.es2000.it/>

_________________________________________________________________
Privacy e riservatezza: il presente messaggio, così come i relativi
allegati, contengono dati ed informazioni da considerarsi strettamente
riservate ed è indirizzato esclusivamente al destinatario sopra indicato,
il quale è l'unico autorizzato a trattarlo in osservanza delle norme del
Regolamento UE 2016/679 (RGPD). Chiunque ricevesse questo messaggio per
errore di evitare di copiarlo, divulgarlo, distribuirlo a terzi e di dare
notizia al mittente dell’errato invio, distruggendo poi l'eventuale copia
cartacea e la copia in formato elettronico.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sergey Cherukhin 2023-10-02 08:54:30 Operating of synchronous master when no standby is available
Previous Message Ron 2023-10-01 22:47:54 Re: Gradual migration from integer to bigint?