Re: SQL Programming Question

Поиск
Список
Период
Сортировка
От Darren Duncan
Тема Re: SQL Programming Question
Дата
Msg-id 4C8BC866.1030702@darrenduncan.net
обсуждение исходный текст
Ответ на Re: SQL Programming Question  (Martin Gainty <mgainty@hotmail.com>)
Список pgsql-general
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

В списке pgsql-general по дате отправления:

Предыдущее
От: Jeff Davis
Дата:
Сообщение: Re: Regular expression that splits CSV string into table
Следующее
От: Merlin Moncure
Дата:
Сообщение: Re: SQL Programming Question