Re: unique & update - Mailing list pgsql-general

From Gregory Wood
Subject Re: unique & update
Date
Msg-id 02a001c1aa8d$3ec45750$7889ffcc@comstock.com
Whole thread Raw
In response to Re: unique & update  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-general
> How can I rollback in a function ?
> I mean after update has been done, I do some checking in the Function and
> then decide that I want to quit and rollback all what inserted/updated in
> the start of the function ?

Just do:
  RAISE EXCEPTION ''I did some checking, and decided to quit and rollback'';

> Also if I attach trigger that check column uniqueness to an update will it
> check it per updated row or at the end of the action after all the table
got
> updated ?

By default, it checks after the row was updated, but you can make it
INITIALLY DEFERRED which will wait until after the transaction to check. To
be honest, I'm not sure if you have to declare it DEFERRABLE as well, or if
the INITIALLY DEFERRED will handle both.

Greg


pgsql-general by date:

Previous
From: "Ben-Nes Michael"
Date:
Subject: Re: unique & update
Next
From: "Gregory Wood"
Date:
Subject: Drop Foreign Key