pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
There is error at the examples in PL/pgSQL
3+ messages / 3 participants
[nested] [flat]

* There is error at the examples in PL/pgSQL
@ 2001-03-05 02:43 Lu Raymond <raymond_lu99@hotmail.com>
  2001-03-06 19:24 ` Re: There is error at the examples in PL/pgSQL Stephan Szabo <sszabo@megazone23.bigpanda.com>
  2001-03-06 19:53 ` Re: There is error at the examples in PL/pgSQL Jie Liang <jliang@ipinc.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Lu Raymond @ 2001-03-05 02:43 UTC (permalink / raw)
  To: pgsql-admin

Hello,all

I use your a example of PL/pgSQL, but there are 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.




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: There is error at the examples in PL/pgSQL
  2001-03-05 02:43 There is error at the examples in PL/pgSQL Lu Raymond <raymond_lu99@hotmail.com>
@ 2001-03-06 19:24 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Stephan Szabo @ 2001-03-06 19:24 UTC (permalink / raw)
  To: Lu Raymond <raymond_lu99@hotmail.com>; +Cc: pgsql-admin


You probably copied it from a machine that uses CR/LF rather than LF as
newline.  I think 7.1 handles this but earlier ones will fail.  Trim
the CR characters and it should work.

On Mon, 5 Mar 2001, Lu Raymond wrote:


> 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!




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: There is error at the examples in PL/pgSQL
  2001-03-05 02:43 There is error at the examples in PL/pgSQL Lu Raymond <raymond_lu99@hotmail.com>
@ 2001-03-06 19:53 ` Jie Liang <jliang@ipinc.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Jie Liang @ 2001-03-06 19:53 UTC (permalink / raw)
  To: Lu Raymond <raymond_lu99@hotmail.com>; +Cc: pgsql-admin

what's version psql you working on??
I pasted your example, it works fine.
you might miss something...

Jie LIANG

St. Bernard Software

10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873

jliang@ipinc.com
www.stbernard.com
www.ipinc.com

On Mon, 5 Mar 2001, Lu Raymond wrote:

> Hello,all
> 
> I use your a example of PL/pgSQL, but there are 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.
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
> 




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2001-03-06 19:53 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-03-05 02:43 There is error at the examples in PL/pgSQL Lu Raymond <raymond_lu99@hotmail.com>
2001-03-06 19:24 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2001-03-06 19:53 ` Jie Liang <jliang@ipinc.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox