Subject Re: [firebird-support] Performance question (repost)
Author Dimitry Sibiryakov
On 22 Jun 2003 at 13:54, Paul Vinkenoog wrote:

>C: write an SP InsertOrUpdate taking all the necessary parameters.
>Have
> the SP do an EXISTS test and act upon that. This way, you keep the
> testing on the server side, the data go only over the wire once.
>
>Which one is quickest depends on lots of factors, though.

According to tests by Alex Cherednichenko the fastest way to do
InsertOrUpdate is this (by Dmitri Popov):

K=NULL;
FOR SELECT ...... INTO :K AS CURSOR TMP DO
UPDATE ..... WHERE CURRENT OF TMP;
IF (K IS NULL) THEN
INSERT INTO ....

Of course, column for selecting must be not nullable.

You can find the article on www.ibase.ru

SY, Dimitry Sibiryakov.