Skip site navigation (1) Skip section navigation (2)

Re: Insert vs Update syntax

From: Brent Friedman <bfriedman(at)scanonline(dot)com>
To: Clodoaldo <clodoaldo(dot)pinto(dot)neto(at)gmail(dot)com>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, PostgreSQL - General ML <pgsql-general(at)postgresql(dot)org>
Subject: Re: Insert vs Update syntax
Date: 2008-02-29 17:13:58
Message-ID: 47C83D56.2060202@scanonline.com (view raw or flat)
Thread:
Lists: pgsql-general
If you don't like the standard sql implementation, you could use plsql 
or any language to make an abstraction layer/wrapper for this 
functionality.  Just pass everything as a key/value pair, in an array or 
hashtable structure, to your abstraction layer/wrapper, and it can cycle 
through the data structure to do the insert or update for you.

In very rough psuedo-code, something like

    create my_data_structure {
           table = employees,
           first_name = sally,
           last_name = smith,
           date_of_birth = 2008-01-01
    }

    call function mywrapper (my_data_structure)

          .....
          function cycles through array, and creates an sql string 
dynamically

This may have problems with constraints, foreign keys, etc.
   

Clodoaldo wrote:
> 2008/2/29, Martijn van Oosterhout <kleptog(at)svana(dot)org>:
>   
>> On Fri, Feb 29, 2008 at 01:17:20PM -0300, Clodoaldo wrote:
>>  > When inserting into a table and there are many columns to be inserted
>>  > it is hard to synchronize columns to values:
>>
>>
>> <snip>
>>
>>
>>  > Is there some reason for the insert syntax to be the way it is in
>>  > instead of the much easier to get it right Update syntax?:
>>
>>
>> Because it's what the SQL standard says. If you don't like it I suggest
>>  you take it up with them... But it's a little late to change now I
>>  think.
>>     
>
> I know about the standards and I'm not blaming postgresql. I just want
> to know if it is worth to bring the the matter to some responsible
> group.
>
> Regards, Clodoaldo Pinto Neto
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>
>   


In response to

Responses

pgsql-general by date

Next:From: Scara MaccaiDate: 2008-02-29 17:19:27
Subject: Re: partitioning using dblink
Previous:From: Chris BowlbyDate: 2008-02-29 17:09:02
Subject: issue with an assembled date field

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group