Problem with trigger function

Поиск
Список
Период
Сортировка
От Mira Dimitrijevic
Тема Problem with trigger function
Дата
Msg-id 3936E50E-763C-4536-9B42-0D68B57902E4@lanl.gov
обсуждение исходный текст
Ответы Re: Problem with trigger function  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Список pgsql-general
Hi,
I wrote the trigger function below and when trying to execute it, I
get the following error:

  15:00:42  [CREATE - 0 row(s), 0.000 secs]  [Error Code: 0, SQL
State: 42601]  ERROR: syntax error at or near "INSERT"

I am using DBVisualizer's "SQL Commander" window, not the "create
funciton" option. I know the SQL is correct - I can execute it just
by itself. The problem is somewhere in the
syntax for a postgres trigger function. Any input on what the problem
might be would be just fabulous!

Many thanks,
Mira




CREATE OR REPLACE FUNCTION audit_sequence_update() RETURNS trigger AS '
BEGIN
     IF tg_op = ''INSERT'' THEN
         INSERT INTO audit_sequence_update(operation, "day",
owner_uid, "sequence")
         VALUES
         ('INSERT', NEW."day", NEW.owner_uid, NEW."sequence");
     ELSE
         INSERT INTO audit_sequence_update(operation, "day",
owner_uid, "sequence")
         SELECT
         'UPDATE', "day", owner_uid, "sequence"
         FROM sequence where isdid=NEW.isdid;
     END IF;
     RETURN NEW;
END
' LANGUAGE plpgsql;

В списке pgsql-general по дате отправления:

Предыдущее
От: "Akhtar Yasmin-B05532"
Дата:
Сообщение: Postgres does not start, gives no error
Следующее
От: Raymond O'Donnell
Дата:
Сообщение: Re: Postgres does not start, gives no error