pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Rama Krishnan <raghuldrag@gmail.com>
To: Postgres General <pgsql-general@postgresql.org>
Subject: Re: Function inside query status
Date: Thu, 30 Jun 2022 07:40:13 -0700
Message-ID: <a950e012-c367-5196-b98f-429713346fde@aklaver.com> (raw)
In-Reply-To: <CAJWX+EN7KBmA1MTsjz_-ZaC4ZM-=7oU5uo-nkWkp1YS6FhAoYg@mail.gmail.com>
References: <CAJWX+EN7KBmA1MTsjz_-ZaC4ZM-=7oU5uo-nkWkp1YS6FhAoYg@mail.gmail.com>

On 6/29/22 23:57, Rama Krishnan wrote:
> Hi All,
> 
> 
> Is it possible to check the query execution status inside the function.
> 
> 
> 
>   created or replace function data_purge() returns void as$$
> Declare
> Begin
> Drop table test_old;
> Create table test_old as select * from sales where bill_date<now() 
> -interval '1 year';
> 
> Delete table sales where sales_id in (select sales_id from test_old;

1) You are not actually declaring anything so the Declare is not needed.

2) You have three queries in the function do you want to check them all 
or some subset?

3) What exactly are checking for?

4) Have you looked at?:

https://www.postgresql.org/docs/current/plpgsql-statements.html#PLPGSQL-STATEMENTS-DIAGNOSTICS

and

https://www.postgresql.org/docs/current/plpgsql-control-structures.html#PLPGSQL-EXCEPTION-DIAGNOSTIC...

> 
> End;
> $$ language plpgsql;
> 
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (2+ messages)

Message-ID: <a950e012-c367-5196-b98f-429713346fde@aklaver.com>
Permalink:  ../a950e012-c367-5196-b98f-429713346fde@aklaver.com/
Also on:    postgresql.org/message-id/a950e012-c367-5196-b98f-429713346fde@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, raghuldrag@gmail.com
  Subject: Re: Function inside query status
  In-Reply-To: <a950e012-c367-5196-b98f-429713346fde@aklaver.com>
  References: <CAJWX+EN7KBmA1MTsjz_-ZaC4ZM-=7oU5uo-nkWkp1YS6FhAoYg@mail.gmail.com> <a950e012-c367-5196-b98f-429713346fde@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox