Re: Commit / Rollback in PL/pgSQL ?

From: Tino Wildenhain <tino(at)wildenhain(dot)de>
To: mkl(at)webde-ag(dot)de
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Commit / Rollback in PL/pgSQL ?
Date: 2004-10-13 16:04:01
Message-ID: 1097683441.1520.2221.camel@Andrea.peacock.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Am Mi, den 13.10.2004 schrieb Michael Kleiser um 17:44:
> I found on
> http://www.physiol.ox.ac.uk/Computing/Online_Documentation/postgresql/plpgsql-porting.html
> that it is not poosible to use start or end a transaction in plpgsl.
>
> I tried to create a plplsql-function on PostgreSQL 8.0 beta 3
> I can comile
>
> CREATE OR REPLACE FUNCTION insert_many_commit( integer ) RETURNS void AS '
> DECLARE
> counter INTEGER := $1;
> BEGIN
> WHILE counter > 0 LOOP
> INSERT INTO testtab (id, modification_date, description )
> VALUES ( NEXTVAL(''seq_testtab''),now(), ''Eintrag von insert_many() '' || counter );
> COMMIT;
> counter := counter-1;
> END LOOP;
> RETURN;
> END;
> ' LANGUAGE 'plpgsql';
>
> So I think it's possible to have COMMIT / ROLLBACK in PLPgSQL

No, you cant. The whole execution is part of one statement which is
then automatically encapsulated in one transaction. Maybe the
checkpoint features of the upcoming pg8.x help you.

Otoh, why do you want to commit here anyway?

Regards
Tino

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2004-10-13 16:25:14 Re: Proposal: GRANT cascade to implicit sequences
Previous Message Robin Ericsson 2004-10-13 16:01:10 Re: query problem