Re: Default Value in Table Setup Help

From: Adam Kavan <akavan(at)cox(dot)net>
To: Dev <dev(at)umpa-us(dot)com>, Postgresql General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Default Value in Table Setup Help
Date: 2003-08-18 20:40:21
Message-ID: 5.2.1.1.0.20030818153813.009ee9d0@pop.central.cox.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

At 02:57 PM 8/18/03 -0400, 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?

I don't think you can do what you want to do with a column
default. Instead you want to look at the rewrite rules. You can find
information about them here:

http://www.postgresql.org/docs/7.3/interactive/sql-createrule.html

If I'm wrong I'm sure someone here will correct me :).

--- Adam Kavan
--- akavan(at)cox(dot)net

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Vilson farias 2003-08-18 20:44:22 7.3.4 RPM
Previous Message Tom Lane 2003-08-18 20:40:15 Re: Why lower's not accept an AS declaration ?