pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Yudie@axiontech.com <yudie@axiontech.com>
To: pgsql-sql@postgresql.org
Subject: problem with plpgsql trigger function: parse error near ""
Date: Thu, 25 Jul 2002 12:20:13 -0500
Message-ID: <00bc01c233ff$8d5489c0$8a01a8c0@yudie> (raw)

I just tried the trigger function from:
http://developer.postgresql.org/docs/postgres/plpgsql-trigger.html
(You can read the sql command on the bottom of this message.)

When inserting into emp table i got error: --> parse error near ""

I just wondering if any of you have the same probelem;
The plpgsql language was just created with createlang plqpsql [dbname]

Thank you
Yudie

Sample Code:
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();




view thread (3+ messages)  latest in thread

Message-ID: <00bc01c233ff$8d5489c0$8a01a8c0@yudie>
Permalink:  ../00bc01c233ff$8d5489c0$8a01a8c0@yudie/
Also on:    postgresql.org/message-id/00bc01c233ff$8d5489c0$8a01a8c0@yudie

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: yudie@axiontech.com
  Subject: Re: problem with plpgsql trigger function: parse error near ""
  In-Reply-To: <00bc01c233ff$8d5489c0$8a01a8c0@yudie>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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