Re: Default Value in Table Setup Help - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: Default Value in Table Setup Help
Date
Msg-id 20030818202444.GA8331@wolff.to
Whole thread Raw
In response to Default Value in Table Setup Help  (Dev <dev@umpa-us.com>)
List pgsql-general
On Mon, Aug 18, 2003 at 14:57:12 -0400,
  Dev <dev@umpa-us.com> 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?

I think you want to use a trigger to do this. The default function only
gets used if you don't supply a value.

pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Default Value in Table Setup Help
Next
From: Ian Barwick
Date:
Subject: Re: Why lower's not accept an AS declaration ?