From: | Michael Kleiser <mkl(at)webde-ag(dot)de> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Commit / Rollback in PL/pgSQL ? |
Date: | 2004-10-13 15:44:32 |
Message-ID: | 416D4D60.6070005@webde-ag.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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
But I can't execute this funktion this way:
# select insert_many_commit(1000);
ERROR: SPI_execute_plan failed executing query "COMMIT": SPI_ERROR_TRANSACTION
Is there an other way to execute tis function ?
If the latter, is it poosible in other languages like PL/Python or PL/Perl ?
regards
Michael Kleiser
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2004-10-13 15:52:55 | Re: LISTEN/NOTIFY for lightweight replication |
Previous Message | Tom Lane | 2004-10-13 15:34:05 | Re: could not access status of transaction 4244329 |