pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedproblem with plpgsql trigger function: parse error near ""
3+ messages / 3 participants
[nested] [flat]
* problem with plpgsql trigger function: parse error near ""
@ 2002-07-25 17:20 Yudie@axiontech.com <yudie@axiontech.com>
2002-07-25 18:06 ` Re: problem with plpgsql trigger function: parse error near "" Stephan Szabo <sszabo@megazone23.bigpanda.com>
2002-07-25 18:06 ` Re: problem with plpgsql trigger function: parse error near "" Jan Wieck <JanWieck@Yahoo.com>
0 siblings, 2 replies; 3+ messages in thread
From: Yudie@axiontech.com @ 2002-07-25 17:20 UTC (permalink / raw)
To: pgsql-sql
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();
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: problem with plpgsql trigger function: parse error near ""
2002-07-25 17:20 problem with plpgsql trigger function: parse error near "" Yudie@axiontech.com <yudie@axiontech.com>
@ 2002-07-25 18:06 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
1 sibling, 0 replies; 3+ messages in thread
From: Stephan Szabo @ 2002-07-25 18:06 UTC (permalink / raw)
To: Yudie@axiontech.com <yudie@axiontech.com>; +Cc: pgsql-sql
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.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: problem with plpgsql trigger function: parse error near ""
2002-07-25 17:20 problem with plpgsql trigger function: parse error near "" Yudie@axiontech.com <yudie@axiontech.com>
@ 2002-07-25 18:06 ` Jan Wieck <JanWieck@Yahoo.com>
1 sibling, 0 replies; 3+ messages in thread
From: Jan Wieck @ 2002-07-25 18:06 UTC (permalink / raw)
To: Yudie@axiontech.com <yudie@axiontech.com>; +Cc: pgsql-sql
"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
<cut'n'paste>
:set notextmode
:wr filename
:q
psql dbname <filename
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck@Yahoo.com #
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2002-07-25 18:06 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-07-25 17:20 problem with plpgsql trigger function: parse error near "" Yudie@axiontech.com <yudie@axiontech.com>
2002-07-25 18:06 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2002-07-25 18:06 ` Jan Wieck <JanWieck@Yahoo.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