Creating/Using functions in pl/pgsql

Поиск
Список
Период
Сортировка
От Chris Halsberghe
Тема Creating/Using functions in pl/pgsql
Дата
Msg-id F124s4PJ5aAJAFXQWAz00004f5a@hotmail.com
обсуждение исходный текст
Ответы Re: Creating/Using functions in pl/pgsql
Список pgsql-general
When trying to define a trigger and a function (mail_notify) on a
certain table, I received an error notification which I couldn't understand:
<quote>
NOTICE: plpgsql: ERROR during compile of mail_notify near line 1
ERROR: parse error at or near "
</quote>
I could not see any syntax error in the definition of the function, which
was accepted by the postmaster
at creation time without complaints.
Then I tried to code the example from the Programmer's Manual, Chapter 24

Here is the text for that example:
<quote>
Example 24-1. A PL/pgSQL Trigger Procedure Example
This trigger ensures, that any time a row is inserted or updated in the
table, the current user name and
time are stamped into the row. And it ensures that an employees name is
given and that the salary is a
positive value.

CREATE TABLE emp (
empname text,
salary integer,
last_date timestamp,
last_user text
);

CREATE FUNCTION emp_stamp () RETURNS OPAQUE AS ’
BEGIN
-- Check that empname and salary are given
IF NEW.empname ISNULL THEN
RAISE EXCEPTION ’’empname cannot be NULL value’’;
END IF;
IF NEW.salary ISNULL THEN
RAISE EXCEPTION ’’% cannot have NULL salary’’,
NEW.empname;
END IF;
-- Who works for us when she must pay for?
IF NEW.salary < 0 THEN
RAISE EXCEPTION ’’% cannot have a negative salary’’,
NEW.empname;
END IF;
-- Remember who changed the payroll when
NEW.last_date := ’’now’’;
NEW.last_user := current_user;
RETURN NEW;
END;
’ LANGUAGE ’plpgsql’;

CREATE TRIGGER emp_stamp BEFORE INSERT OR UPDATE ON emp
FOR EACH ROW EXECUTE PROCEDURE emp_stamp();

</quote>


I get exactly the same kind of error message from the postmaster:
<quote>
NOTICE: plpgsql: ERROR during compile of emp_stamp near line 1
ERROR: parse error at or near "
</quote>

What is the explanation of this behaviour?

Chris

_________________________________________________________________
Download MSN Explorer gratis van http://explorer.msn.nl/intl.asp


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

Предыдущее
От: Chris Ryan
Дата:
Сообщение: [PHP] Re: [NOVICE] psql with PHP question
Следующее
От: Cristóvão Dalla Costa
Дата:
Сообщение: Re: GUI?