From: | Emi Lu <emilu(at)encs(dot)concordia(dot)ca> |
---|---|
To: | Bruno Wolff III <bruno(at)wolff(dot)to> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: in Pl/PgSQL, do commit every 5000 records |
Date: | 2006-03-10 17:12:51 |
Message-ID: | 4411B393.7020307@encs.concordia.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I got the answer. Although the compile passed, when it reaches 5000, the
commit command causes a "SPI_ERROR_TRANSACTION" exception.
Thank you for all your hint.
>> You can't do commits inside of a function.
>
>
> The example I have is:
>
> CREATE OR REPLACE function test() returns boolean AS $$
> DECLARE
> ... ...
> counter INTEGER := 0;
> BEGIN
> ... ...
> query_value := ' .....' ;
> OPEN curs1 FOR EXECUTE query_value;
> LOOP
> FETCH curs1 INTO studid;
> EXIT WHEN NOT FOUND;
>
> query_value := ' INSERT INTO ... ...';
> EXECUTE query_value ;
>
> counter := counter + 1 ;
> IF counter%5000 = 0 THEN
> counter := 0;
> COMMIT;
> END IF;
>
> END LOOP;
>
>
> CLOSE curs1; ...
> END;
>
> ... ...
>
> The above function works ok.
> "can't do commits inside of a function " , do you mean although the
> function complied ok and run successfully, but it did not really
> commit insertion actions at every 5000 records?
>
>> I think you are misremembering advice about not do inserts with a
>> transaction per row which will have
>> a lot of overhead for all of the commits
>
From | Date | Subject | |
---|---|---|---|
Next Message | Florian G. Pflug | 2006-03-10 17:18:28 | Re: in Pl/PgSQL, do commit every 5000 records |
Previous Message | Harco de Hilster | 2006-03-10 16:57:10 | ERROR: FULL JOIN is only supported with merge-joinable join conditions |