trigger errors - Mailing list pgsql-general

From Marc Britten
Subject trigger errors
Date
Msg-id ABFF67479EC9D111AFA30060B01AACDA03ADF68B@mail
Whole thread Raw
List pgsql-general
hi again,

i created a trigger on a table for insert or delete, and a function that
gets created fine.

however when i go to insert something into the table i get

NOTICE:  plpgsql: ERROR during compile of create_count_cache near line 2
ERROR:  parse error at or near ";"

definitions follow(this is the exact syntax and order i used to create the
function table and trigger, all other tables in referenced do exist and have
ALL permissions turned on for the user)

CREATE FUNCTION create_count_cache()
       RETURNS opaque AS
       '
     BEGIN;
     DELETE FROM LangCount;
     INSERT INTO LangCount SELECT LangID as ID, COUNT(LangID) AS CNT
FROM snippet GROUP BY LangID;
     DELETE FROM CatCount;
     INSERT INTO CatCount SELECT LangID as ID, COUNT(LangID) AS CNT FROM
snippet GROUP BY LangID;
     COMMIT;
       '
       LANGUAGE 'plpgsql';


CREATE TABLE snippet (
       UserName         VARCHAR(12),
       LangID         INT,
       CatID         INT DEFAULT 0,
       name         VARCHAR(30),
       snippet         TEXT);
grant ALL ON snippet to codelibrary;

CREATE INDEX front_select ON snippet (UserName, LangID, name);
CREATE INDEX cat_select ON snippet (UserName, CatID, name);

CREATE TRIGGER count_change
       AFTER DELETE OR INSERT ON snippet FOR EACH ROW
       EXECUTE PROCEDURE create_count_cache();

i then call

insert into snippet (UserName, LangID, name, snippet)
 values ('mbritten', 1, 'my snippet', 'int i = 0;');

and get the error.

thanks for your time,

marc britten

pgsql-general by date:

Previous
From: NEERAJ BANSAL
Date:
Subject: Help:How do you find that how much storage is taken by the database??
Next
From: Tatsuo Ishii
Date:
Subject: Re: Large objects