problem with plpgsql trigger function: parse error near ""
problem with plpgsql trigger function: parse error near ""
От:
"Yudie@axiontech.com" <yudie@axiontech.com>
Дата:
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();
Re: problem with plpgsql trigger function: parse error near ""
От:
Stephan Szabo <sszabo@megazone23.bigpanda.com>
Дата:
On Thu, 25 Jul 2002, Yudie@axiontech.com wrote: > 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; What version are you running? The below cut and paste into my 7.3 devel server and a 7.2 server seems to work.
Re: problem with plpgsql trigger function: parse error near ""
От:
Jan Wieck <JanWieck@Yahoo.com>
Дата:
"Yudie@axiontech.com" wrote: > > 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.) There have been issues with carriage-returns in PL/pgSQL. If you cut'n'pasted that from the HTML into some file or directly into a psql prompt, you likely got bitten by that. Try to put the content into a file and make sure that is only has linefeeds. vi :set notextmode :wr filename :q psql dbname