Re: easy way to insert same value into 2 columns

Csaba Nagy <nagy@ecircle-ag.com>

From: Csaba Nagy <nagy@ecircle-ag.com>
To: Sebastian Boeck <sebastianboeck@freenet.de>
Cc: Postgres general mailing list <pgsql-general@postgresql.org>
Date: 2003-10-16T10:03:09Z
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