Re: get value after updating table

From: "Martin Gainty" <mgainty(at)hotmail(dot)com>
To: "Alain Roger" <raf(dot)news(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: get value after updating table
Date: 2007-03-26 20:06:55
Message-ID: BAY133-DAV13AB3A2168861FE0D30F17AE6F0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

roger-
you need an exception block as in...
CREATE OR REPLACE FUNCTION sp_a_005("login" "varchar", pwd "varchar")
RETURNS boolean AS
$BODY$

BEGIN
UPDATE...
EXCEPTION
WHEN NO_DATA_FOUND
RETURN FALSE
WHEN PROGRAM_ERROR
RETURN FALSE
WHEN OTHERS
RETURN FALSE
RETURN TRUE
END;
---------------------------------------------------------------------------
This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited.
---------------------------------------------------------------------------
Le présent message électronique (y compris les pièces qui y sont annexées, le cas échéant) s'adresse au destinataire indiqué et peut contenir des renseignements de caractère privé ou confidentiel. Si vous n'êtes pas le destinataire de ce document, nous vous signalons qu'il est strictement interdit de le diffuser, de le distribuer ou de le reproduire.
----- Original Message -----
From: Alain Roger
To: pgsql-general(at)postgresql(dot)org
Sent: Monday, March 26, 2007 3:38 PM
Subject: [GENERAL] get value after updating table

Hi,

I wrote a function which should update a table field.
However, i would like somehow to control that update was done.
for that i was thinking to return a boolean : true is update was done, false if an error happened.

however, i can i do that ? I mean how can i know if UPDATE has been correctly executed ?

here is my function :
CREATE OR REPLACE FUNCTION sp_a_005("login" "varchar", pwd "varchar")
RETURNS boolean AS
$BODY$

DECLARE

BEGIN
UPDATE accounts
SET account_pwd = $2
WHERE account_login = $1;
RETURN;

END;

--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.1.4
Apache 2.0.58
PHP 5

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ron 2007-03-26 20:31:42 A (hopefully) simple question re: secure pg <=> web application access
Previous Message Alain Roger 2007-03-26 19:38:07 get value after updating table