Re: SET syntax in INSERT - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: SET syntax in INSERT
Date
Msg-id 20090825190253.GJ12604@alvh.no-ip.org
Whole thread Raw
In response to Re: SET syntax in INSERT  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
List pgsql-hackers
Heikki Linnakangas escribió:

> I do understand the point, though - it's much easier to edit and debug
> long statements when the value is close to the column name. I find that
> the INSERT .. SELECT makes that a lot nicer:
> 
> INSERT INTO t
> (col1,col2,col3,col4,col5,col6,col7,col8,col9,col10,col11,col12,col13,col14,col15)
> SELECT 'val1' AS col1,
>        'val2' AS col2,

This example lists the columns twice, which is lame (you have to keep
both in sync) -- and if you take the first list out it works, but the
values can end up in the wrong places if they are not in the same order
as the columns in the table.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: SET syntax in INSERT
Next
From: "Kevin Grittner"
Date:
Subject: Re: We should Axe /contrib/start-scripts