Trouble with Savepoints in postgres

From: sam <sam(dot)mahindrakar(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Trouble with Savepoints in postgres
Date: 2008-03-11 20:49:50
Message-ID: a4b44ce8-423c-4844-8d93-fec99728f582@i29g2000prf.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Iam not able to use savepoints i postgres.
Iam using version 8.2.
If i write something like this :
CREATE OR REPLACE FUNCTION test_savepoint()
RETURNS void AS
$BODY$
DECLARE

BEGIN
SAVEPOINT foo;
INSERT INTO table1 VALUES (3);

INSERT INTO table1 VALUES (4);
ROLLBACK TO foo;
COMMIT;

END;

$BODY$
LANGUAGE 'plpgsql' VOLATILE;

when i try to excute this function it throws me an error:
ERROR: SPI_execute_plan failed executing query "SAVEPOINT foo":
SPI_ERROR_TRANSACTION
SQL state: XX000

Iam not able to understand if this is a version problem or the way iam
using savepoints is wrong.Please advice.

Thanks
Sam

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-03-11 20:50:50 Re: How to convert postgres timestamp to date: yyyy-mm-dd
Previous Message Colin Wetherbee 2008-03-11 20:35:14 Re: Array load from remote site through Perl/DBI