Re: Rule to fill in value on column on insert

From: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
To: "Bradley Kieser" <brad(at)kieser(dot)net>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Rule to fill in value on column on insert
Date: 2002-06-10 08:44:33
Message-ID: GNELIHDDFBOCMGBFGEFOAEKOCCAA.chriskl@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi Bradley,

If it's a simple value, then set the column's defaul (ALTER TABLE tab ALTER
col SET DEFAULT blah). Otherwise, look up CREATE TRIGGER and CREATE RULE in
the docs.

Chris

> -----Original Message-----
> From: pgsql-sql-owner(at)postgresql(dot)org
> [mailto:pgsql-sql-owner(at)postgresql(dot)org]On Behalf Of Bradley Kieser
> Sent: Monday, 10 June 2002 4:26 PM
> To: pgsql-sql(at)postgresql(dot)org
> Subject: [SQL] Rule to fill in value on column on insert
>
>
> How do I create a rule that will set a column to a particular value upon
> insert? It's for use within an audit trail and we want to prevent any
> possibility of some rogue code setting it to an incorrect value (it's a
> time stamp) so we don't want to use default values.
>
> In general, though, it would be handy to know how to do this as there
> are many uses for it!
>
> Thanks,
>
> Brad
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Achilleus Mantzios 2002-06-10 12:09:05 VIEWs and FOREIGN keys
Previous Message Bradley Kieser 2002-06-10 08:25:52 Rule to fill in value on column on insert