SPI_ERROR_TRANSACTION [PostgreSQL 8.3] - Mailing list pgsql-general

From Daroslav
Subject SPI_ERROR_TRANSACTION [PostgreSQL 8.3]
Date
Msg-id 23277399.post@talk.nabble.com
Whole thread Raw
Responses Re: SPI_ERROR_TRANSACTION [PostgreSQL 8.3]
List 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.


pgsql-general by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: postgres only in local socket
Next
From: Allan Kamau
Date:
Subject: Re: Web + Slicing/Paging datas