Re: easy way to insert same value into 2 columns - Mailing list pgsql-general

From Csaba Nagy
Subject Re: easy way to insert same value into 2 columns
Date
Msg-id 1066298590.10614.25.camel@coppola.ecircle.de
Whole thread Raw
In response to easy way to insert same value into 2 columns  (Sebastian Boeck <sebastianboeck@freenet.de>)
Responses Re: easy way to insert same value into 2 columns  (Sebastian Boeck <sebastianboeck@freenet.de>)
List 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



pgsql-general by date:

Previous
From: Sebastian Boeck
Date:
Subject: easy way to insert same value into 2 columns
Next
From: Sebastian Boeck
Date:
Subject: Re: easy way to insert same value into 2 columns