Re: SET syntax in INSERT

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Rob Wultsch <wultsch(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: SET syntax in INSERT
Date: 2009-08-25 19:00:12
Message-ID: 162867790908251200s2b1bc052w413e8113f46f6d1e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> For an insert with many columns or with large value this syntax can
> significantly improve readability. So it wasn't invented here, so
> what? I don't see a downside to allowing this syntax other than MySQL
> used it first, and there are multiple upsides (readability, easier
> transitions).
>

Insert of too much columns is signal, so your database is badly designed.

If you afraid about readability, you can you named parameters - I hope
so this feature will be early committed. It can look like:

CREATE OR REPLACE FUNCTION insert_tab(p1 varchar = NULL, p2 varchar =
NULL, p3 varchar = NULL, ...
RETURNS void AS $$
INSERT INTO tab(p1,p2,p3,p4....
VALUES($1,$2,$3,$4, ...

then you can call this procedure

SELECT insert_tab(10 as p1, 20 as p3);

regards
Pavel Stehule

> --
> Rob Wultsch
> wultsch(at)gmail(dot)com
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2009-08-25 19:01:00 Re: SET syntax in INSERT
Previous Message Rob Wultsch 2009-08-25 18:19:50 Re: SET syntax in INSERT