Re: easy way to insert same value into 2 columns

From: Csaba Nagy <nagy(at)ecircle-ag(dot)com>
To: Sebastian Boeck <sebastianboeck(at)freenet(dot)de>
Cc: Postgres general mailing list <pgsql-general(at)postgresql(dot)org>
Subject: Re: easy way to insert same value into 2 columns
Date: 2003-10-16 10:03:09
Message-ID: 1066298590.10614.25.camel@coppola.ecircle.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

For your specific question I don't know the answer.

For this particular case you could use:

create table your_table (
id integer default nextval ('public.zeit_id_seq'::text),
pos_id integer default currval ('public.zeit_id_seq'::text),
...
);

That would work fine as long as you use inserts which don't specify id
if pos_id is not specified (otherwise the currval will throw you an
error cause it cannot be called without nextval being called).

HTH,
Csaba.

On Thu, 2003-10-16 at 11:40, Sebastian Boeck wrote:
> Hello,
>
> whats the most simple way to insert the same value into 2 colums of
> the same table?
> My table is looking like this:
>
> Spalte | Typ | Attribute
> --------+---------+----------------------
> id | integer | default nextval ('public.zeit_id_seq'::text)
> pos_id | integer | default xxx
>
> for the xxx i want the same value than id be inserted automatically
>
> Regards
>
> Sebastian
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
> joining column's datatypes do not match

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sebastian Boeck 2003-10-16 10:11:51 Re: easy way to insert same value into 2 columns
Previous Message Sebastian Boeck 2003-10-16 09:40:59 easy way to insert same value into 2 columns