SPI_ERROR_TRANSACTION [PostgreSQL 8.3]

From: Daroslav <daroslav(at)g(dot)pl>
To: pgsql-general(at)postgresql(dot)org
Subject: SPI_ERROR_TRANSACTION [PostgreSQL 8.3]
Date: 2009-04-28 13:40:54
Message-ID: 23277399.post@talk.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hi

As a newbie in PL/pgSQL I have faced an error SPI_ERROR_TRANSACTION which
was raised always when I have tried to launch following function with
uncommented keywords SAVEPOINT, SET TRANSACTION and COMMIT(when commented,
function works fine):

CREATE OR REPLACE FUNCTION insert_employee(
name_emp varchar, surname_emp varchar, street_emp varchar, postcode_emp
varchar, city_emp varchar, login_emp varchar, password_emp varchar)
returns boolean as $insert_emp$

DECLARE
last_row_id integer;

BEGIN

--SAVEPOINT my_savepoint;
--SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
INSERT INTO person VALUES (nextval('person_seq'), $1,$2,$3,$4,$5);
IF NOT FOUND THEN
ROLLBACK TO SAVEPOINT my_savepoint;
RAISE EXCEPTION 'New person insertion error';
RETURN false;
END IF;

SELECT currval('public.person_seq') INTO last_row_id;

INSERT INTO employee VALUES (nextval('employee_seq'), last_row_id, $6, $7);
IF NOT FOUND THEN
ROLLBACK TO SAVEPOINT my_savepoint;
RETURN false;
END IF;
--COMMIT;

RETURN true;

END;
$insert_emp$ LANGUAGE plpgsql;

I don't know why these keywords cannot be used in function block if they
works fine in Begin-Commit block. How can I change TRANSACTION type into
SERIALIZABLE within mentioned insert_employee function.

Thanks in advance,
Daroslav

--
View this message in context: http://www.nabble.com/SPI_ERROR_TRANSACTION--PostgreSQL-8.3--tp23277399p23277399.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Allan Kamau 2009-04-28 14:02:08 Re: Web + Slicing/Paging datas
Previous Message A. Kretschmer 2009-04-28 12:46:36 Re: postgres only in local socket