Received: from mail.postgresql.org (webmail.postgresql.org [216.126.85.28]) by mail.postgresql.org (8.11.1/8.11.1) with SMTP id f26Gb1x30736 for ; Tue, 6 Mar 2001 11:37:01 -0500 (EST) (envelope-from pgsql-docs-owner@postgresql.org) Received: from hotmail.com (f294.law10.hotmail.com [64.4.14.169]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f251qCx00562 for ; Sun, 4 Mar 2001 20:52:13 -0500 (EST) (envelope-from raymond_lu99@hotmail.com) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Sun, 4 Mar 2001 17:52:09 -0800 Received: from 165.21.83.240 by lw10fd.law10.hotmail.msn.com with HTTP; Mon, 05 Mar 2001 01:52:08 GMT X-Originating-IP: [165.21.83.240] From: "Lu Raymond" To: pgsql-docs@postgresql.org Cc: raymond_lu99@hotmail.com Subject: There is error at the examples in PL/pgSQL Date: Mon, 05 Mar 2001 01:52:08 -0000 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 05 Mar 2001 01:52:09.0116 (UTC) FILETIME=[E3819DC0:01C0A516] X-Archive-Number: 200103/24 X-Sequence-Number: 455 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.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 := 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 emp Values('','','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.