Re: Tigger

From: Jaime Casanova <systemguards(at)gmail(dot)com>
To: Bricklen Anderson <BAnderson(at)presinet(dot)com>
Cc: David Hofmann <mor4321(at)hotmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Tigger
Date: 2005-07-22 19:33:11
Message-ID: c2d9e70e05072212331a7aa6bd@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

David Hofmann wrote:
> > I've look throught the docs and from what I can see the bellow code
> > should work, however I keep getting the error:
> >
> > ERROR: parser: parse error at or near "$" at character 53
> >
> > CREATE FUNCTION session_update() RETURNS trigger AS $session_update$
> > BEGIN
> > -- Check date exists
> > IF NEW.stamp_lastupdate IS NULL THEN
> > NEW.stamp_lastupdate := 'now';
> > END IF;
> > RETURN NEW;
> > END;
> >
> > $session_update$ LANGUAGE plpgsql;
> >
> > CREATE TRIGGER session_update BEFORE INSERT OR UPDATE ON sessions FOR
> > EACH ROW EXECUTE PROCEDURE session_update();
> >
> >
> > Any help or suggestions of websites I should read would be appercated.
> >
> > David
>
> Which version of postgresql are you using? I don't believe that the "$" quoting
> was available in older versions than 8 (or late 7?).
>

the $ quoting is available since 8.

This seems bad to me also:
> > CREATE FUNCTION session_update() RETURNS trigger AS $session_update$
> > [..function body..]
> > $session_update$ LANGUAGE plpgsql;

I think it should be:
CREATE FUNCTION session_update() RETURNS trigger AS $$
[..function body..]
$$ LANGUAGE plpgsql;

--
Atentamente,
Jaime Casanova
(DBA: DataBase Aniquilator ;)

In response to

  • Re: Tigger at 2005-07-22 19:17:41 from Bricklen Anderson

Responses

  • Re: Tigger at 2005-07-22 19:35:18 from Bricklen Anderson

Browse pgsql-sql by date

  From Date Subject
Next Message Bricklen Anderson 2005-07-22 19:35:18 Re: Tigger
Previous Message Bricklen Anderson 2005-07-22 19:28:32 Re: Tigger