There is error at the examples in PL/pgSQL

Поиск
Список
Период
Сортировка
От Lu Raymond
Тема There is error at the examples in PL/pgSQL
Дата
Msg-id F171uNY1SWoBDyseVwr0000551c@hotmail.com
обсуждение исходный текст
Ответы Re: There is error at the examples in PL/pgSQL  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hello,all

I use your a example of PL/pgSQL, but I found some errors when I execute 
these codes. The details are followings,

First, I create a exam.sql that includes these codes as followings,

CREATE TABLE emp (  empname text,  salary int4,  last_date datetime,  last_user name);

CREATE FUNCTION emp_stamp () RETURNS OPAQUE AS'  BEGIN      -- Check that empname and salary are given      IF
NEW.empnameISNULL THEN          RAISE EXCEPTION ''empname cannot be NULL value'';      END IF;      IF NEW.salary
ISNULLTHEN          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
negativesalary'', NEW.empname;      END IF;
 
      -- Remember who changed the payroll when      NEW.last_date := ''now'';      NEW.last_user := getpgusername();
 RETURN NEW;  END;
 
' LANGUAGE 'plpgsql';

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



Secondly, I execute exam.sql and the postgress can create the table emp,
the function emp_stamp() and the trigger emp_stamp seccessfully.But when I 
insert one record to table emp, there are some errors on the screen. the insert statement is followings,    INSERT INTO
empValues('','','20001220','raymond');
 

the error of screen is:
NOTICE: plpgsql: ERROR during compile of emp_stamp near line 1
"RROR: parse error at or near "

Why? and what wrong is it? Please give me reply as possible as you can. 
Thanks!









_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.



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

Предыдущее
От: Thomas Lockhart
Дата:
Сообщение: Re: CORBA and PG
Следующее
От: Tom Lane
Дата:
Сообщение: Re: AW: WAL-based allocation of XIDs is insecure