Search Postgresql Archives

Re: SQL Programming Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Martin Gainty wrote:
-- i usually
INSERT the record
--then check for PK VIOLATION e.g.
IF PK_VIOLATION then UPDATE record

is FoxPro still supported???

My understanding is that exception handling carries significant overhead and so doing it within a heavy-iterated loop like this import would perform badly. Partly for that reason and partly for code readability, I would recommend instead the suggestion of copy the whole source to a staging table with COPY and then use a single SQL statement to reconcile/integrate that staging table with the main table.

In particular, I like the staging table approach because the single SQL statement afterwards is a concise declarational code saying what you actually want to do, relative to a client-interfacing loop which is a more verbose imperative version.

-- Darren Duncan

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux