pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bricklen Anderson <BAnderson@PresiNET.com>
To: David Hofmann <mor4321@hotmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Tigger
Date: Fri, 22 Jul 2005 12:28:32 -0700
Message-ID: <42E148E0.9080809@PresiNET.com> (raw)
In-Reply-To: <BAY105-F24DA8FFE3A2AAC07AD2B85BBC90@phx.gbl>
References: <BAY105-F24DA8FFE3A2AAC07AD2B85BBC90@phx.gbl>

David Hofmann wrote:
> I'm using 7.3.
> 
>> From: Bricklen Anderson <BAnderson@PresiNET.com>
>> To: David Hofmann <mor4321@hotmail.com>
>> CC: pgsql-sql@postgresql.org
>> Subject: Re: [SQL] Tigger
>> Date: Fri, 22 Jul 2005 12:17:41 -0700
>>
>> 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?).

I don't think that it worked then. Simple test:

CREATE FUNCTION session_update() RETURNS trigger AS '
BEGIN
	-- Check date exists
	IF NEW.stamp_lastupdate IS NULL THEN
		NEW.stamp_lastupdate := ''now'';
	END IF;
	RETURN NEW;
END;
' LANGUAGE plpgsql;

-- 
_______________________________

This e-mail may be privileged and/or confidential, and the sender does
not waive any related rights and obligations. Any distribution, use or
copying of this e-mail or the information it contains by other than an
intended recipient is unauthorized. If you received this e-mail in
error, please advise me (by return e-mail or otherwise) immediately.
_______________________________



view thread (7+ messages)  latest in thread

Message-ID: <42E148E0.9080809@PresiNET.com>
Permalink:  ../42E148E0.9080809@PresiNET.com/
Also on:    postgresql.org/message-id/42E148E0.9080809@PresiNET.com

 · 

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: BAnderson@PresiNET.com, mor4321@hotmail.com
  Subject: Re: Tigger
  In-Reply-To: <42E148E0.9080809@PresiNET.com>

* 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