Re: auto-filling a field on insert

From: semi-ambivalent <thefronny(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: auto-filling a field on insert
Date: 2009-10-22 03:54:53
Message-ID: 158dd94b-ba9d-4ed8-887e-3fccc6d471e6@x25g2000prf.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Oct 21, 8:54 pm, da(dot)(dot)(dot)(at)fetter(dot)org (David Fetter) wrote:
> On Wed, Oct 21, 2009 at 07:17:44PM -0700, semi-ambivalent wrote:
> > If I have a table with fields A, B, C and D how could I do something
> > such that if I insert values in fields A, B and C field D would be
> > auto-filled with the value A||B||C? Just a pointer of where to begin
> > looking is fine. Triggers? Copy ... From? Table or field
> > definitions?
>
> Instead of populating your table with this extra information, create a
> VIEW with what you want in it.
>
> Cheers,
> David.
> --
> David Fetter <da(dot)(dot)(dot)(at)fetter(dot)org>http://fetter.org/
> Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
> Skype: davidfetter      XMPP: david(dot)fet(dot)(dot)(dot)(at)gmail(dot)com
>
> Remember to vote!
> Consider donating to Postgres:http://www.postgresql.org/about/donate
>
> --
> Sent via pgsql-general mailing list (pgsql-gene(dot)(dot)(dot)(at)postgresql(dot)org)
> To make changes to your subscription:http://www.postgresql.org/mailpref/pgsql-general

At first blush that looks good but I need an index on that concatted
value and I don't seem to be able to index a field in a view. I'll
check the docs on views to see if I'm missing something.

thanks!

sa

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adam Rich 2009-10-22 04:18:04 Preventing database listing?
Previous Message David Jantzen 2009-10-22 03:52:59 Reversing flow of WAL shipping