Re: Returning a bool on DELETE in a proc.

From: "Keith Worthington" <keithw(at)narrowpathinc(dot)com>
To: KPFERL Robert <robert(dot)koepferl(at)sonorys(dot)at>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Returning a bool on DELETE in a proc.
Date: 2005-01-18 18:46:23
Message-ID: 20050118184623.M60170@narrowpathinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> Hi,
>
> I'm currently writing a function which encapsulates a delete and should
> return a bool as indicator for success.
>
> I tried:
>
> DELETE FROM "TariffDetails" WHERE "TariffId"=$1 and "BNumberPrefix"=$2;
> SELECT TRUE;
>
> but this makes me not happy.
> How can I distingruish wehter DELETE affected 0 or more rows and
> return that while DELETE is not capable of returning any value?
>
> And is the whole function executed if the DELETE fails or will it
> stop bevore the select?
>
> I had a read throu SQL-functions while nothing matched me.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

Robert,

I do not know what version you are working with but here is the 7.4
documentation on result status.

http://www.postgresql.org/docs/7.4/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-DIAGNOSTICS

Kind Regards,
Keith

PS I am a novice myself so don't put too much faith in my post. ;-)

______________________________________________
99main Internet Services http://www.99main.com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Fuhr 2005-01-18 18:52:02 Re: Returning a bool on DELETE in a proc.
Previous Message KÖPFERL Robert 2005-01-18 16:17:49 Re: query configuration for validate empty quote to zero