triggers, transactions and locks

From: "C G" <csgcsg39(at)hotmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: triggers, transactions and locks
Date: 2004-12-06 15:46:31
Message-ID: BAY101-F376F54422B0A105BB6D943C5B40@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dear All,

Is there a way to use locks within a trigger? My example below gives the
error:
ERROR: unexpected error -8 in EXECUTE of query "BEGIN"
CONTEXT: PL/pgSQL function "insert_into_t1" line 6 at execute statement

Thanks

Colin

CREATE FUNCTION insert_into_t1() RETURNS trigger AS'
DECLARE
set_qry text;
BEGIN

set_qry:=''BEGIN WORK'';
execute set_qry;
LOCK t1;
INSERT INTO t2 VALUES (11);
COMMIT;
RETURN NEW;
END;
' LANGUAGE 'plpgsql' SECURITY DEFINER;

CREATE TRIGGER insert_into_t1 BEFORE INSERT
ON t1 FOR EACH ROW EXECUTE
PROCEDURE insert_into_t1();

Responses

Browse pgsql-general by date

  From Date Subject
Next Message alex 2004-12-06 15:47:20 Re: DBD::PgSPI 0.02
Previous Message Tom Lane 2004-12-06 15:40:58 Re: select single entry and its neighbours using direct-acess to index?