From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
---|---|
To: | Dev <dev(at)umpa-us(dot)com> |
Cc: | Postgresql General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Default Value in Table Setup Help |
Date: | 2003-08-18 20:22:43 |
Message-ID: | 20030818132147.X35593-100000@megazone.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, 18 Aug 2003, Dev wrote:
> Hello all,
>
> I am working on setting up a table that will append a sequence to the end
> of the value inserted.
> Example;
> INSERT INTO test (test) VALUES ('abcd');
> And have the data in the database be;
> abcd0001
>
> Now I do have things setup else where were the default value for the field
> is such:
> default ('abcd'::text || lpad(text(nextval('test_sequence'::text)), 4,
> '0'::text))
>
> But i want the "abcd" or what erver to be added in the insert?
>
> What am I missing to make this happen?
You don't want to use a default (since that'll be ignored if you actually
pass in a value for the column). You probably want a before trigger that
alters the value that was inserted before the insertion actually happens.
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Wolff III | 2003-08-18 20:24:44 | Re: Default Value in Table Setup Help |
Previous Message | Ian Barwick | 2003-08-18 20:15:07 | Re: Why lower's not accept an AS declaration ? |