pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Tigger
7+ messages / 3 participants
[nested] [flat]

* Tigger
@ 2005-07-22 19:11 David Hofmann <mor4321@hotmail.com>
  2005-07-22 19:17 ` Re: Tigger Bricklen Anderson <BAnderson@PresiNET.com>
  0 siblings, 1 reply; 7+ messages in thread

From: David Hofmann @ 2005-07-22 19:11 UTC (permalink / raw)
  To: pgsql-sql

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

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Tigger
  2005-07-22 19:11 Tigger David Hofmann <mor4321@hotmail.com>
@ 2005-07-22 19:17 ` Bricklen Anderson <BAnderson@PresiNET.com>
  2005-07-22 19:25   ` Re: Tigger David Hofmann <mor4321@hotmail.com>
  2005-07-22 19:33   ` Re: Tigger Jaime Casanova <systemguards@gmail.com>
  0 siblings, 2 replies; 7+ messages in thread

From: Bricklen Anderson @ 2005-07-22 19:17 UTC (permalink / raw)
  To: David Hofmann <mor4321@hotmail.com>; +Cc: 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?).

-- 
_______________________________

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.
_______________________________



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Tigger
  2005-07-22 19:11 Tigger David Hofmann <mor4321@hotmail.com>
  2005-07-22 19:17 ` Re: Tigger Bricklen Anderson <BAnderson@PresiNET.com>
@ 2005-07-22 19:25   ` David Hofmann <mor4321@hotmail.com>
  2005-07-22 19:28     ` Re: Tigger Bricklen Anderson <BAnderson@PresiNET.com>
  1 sibling, 1 reply; 7+ messages in thread

From: David Hofmann @ 2005-07-22 19:25 UTC (permalink / raw)
  To: BAnderson@PresiNET.com; +Cc: pgsql-sql

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?).
>
>--
>_______________________________
>
>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.
>_______________________________

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Tigger
  2005-07-22 19:11 Tigger David Hofmann <mor4321@hotmail.com>
  2005-07-22 19:17 ` Re: Tigger Bricklen Anderson <BAnderson@PresiNET.com>
  2005-07-22 19:25   ` Re: Tigger David Hofmann <mor4321@hotmail.com>
@ 2005-07-22 19:28     ` Bricklen Anderson <BAnderson@PresiNET.com>
  2005-07-22 19:56       ` Re: Tigger David Hofmann <mor4321@hotmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Bricklen Anderson @ 2005-07-22 19:28 UTC (permalink / raw)
  To: David Hofmann <mor4321@hotmail.com>; +Cc: pgsql-sql

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.
_______________________________



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Tigger
  2005-07-22 19:11 Tigger David Hofmann <mor4321@hotmail.com>
  2005-07-22 19:17 ` Re: Tigger Bricklen Anderson <BAnderson@PresiNET.com>
  2005-07-22 19:25   ` Re: Tigger David Hofmann <mor4321@hotmail.com>
  2005-07-22 19:28     ` Re: Tigger Bricklen Anderson <BAnderson@PresiNET.com>
@ 2005-07-22 19:56       ` David Hofmann <mor4321@hotmail.com>
  0 siblings, 0 replies; 7+ messages in thread

From: David Hofmann @ 2005-07-22 19:56 UTC (permalink / raw)
  To: BAnderson@PresiNET.com; +Cc: pgsql-sql

It didn't error out, however the function didn't work. Specificly the if 
statement. I took out the if statement and it started updating, I put it 
back in and it fails to update. Not sure why. I've confirmed that the 
program not attempting to update the stamp_lastupdate field.   Here what I 
end up with that worked.

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


CREATE TRIGGER session_update BEFORE INSERT OR UPDATE ON sessions FOR EACH 
ROW EXECUTE PROCEDURE session_update();


I appercated the help Bricklen.

David


>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:28:32 -0700
>
>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.
>_______________________________

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Tigger
  2005-07-22 19:11 Tigger David Hofmann <mor4321@hotmail.com>
  2005-07-22 19:17 ` Re: Tigger Bricklen Anderson <BAnderson@PresiNET.com>
@ 2005-07-22 19:33   ` Jaime Casanova <systemguards@gmail.com>
  2005-07-22 19:35     ` Re: Tigger Bricklen Anderson <BAnderson@PresiNET.com>
  1 sibling, 1 reply; 7+ messages in thread

From: Jaime Casanova @ 2005-07-22 19:33 UTC (permalink / raw)
  To: Bricklen Anderson <BAnderson@presinet.com>; +Cc: David Hofmann <mor4321@hotmail.com>; 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 ;)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Tigger
  2005-07-22 19:11 Tigger David Hofmann <mor4321@hotmail.com>
  2005-07-22 19:17 ` Re: Tigger Bricklen Anderson <BAnderson@PresiNET.com>
  2005-07-22 19:33   ` Re: Tigger Jaime Casanova <systemguards@gmail.com>
@ 2005-07-22 19:35     ` Bricklen Anderson <BAnderson@PresiNET.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Bricklen Anderson @ 2005-07-22 19:35 UTC (permalink / raw)
  To: Jaime Casanova <systemguards@gmail.com>; +Cc: pgsql-sql

Jaime Casanova wrote:
> 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;
> 

No, the identifier between the $$ is legit, providing you're at v8 and above.


-- 
_______________________________

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.
_______________________________



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2005-07-22 19:56 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-07-22 19:11 Tigger David Hofmann <mor4321@hotmail.com>
2005-07-22 19:17 ` Bricklen Anderson <BAnderson@PresiNET.com>
2005-07-22 19:25   ` David Hofmann <mor4321@hotmail.com>
2005-07-22 19:28     ` Bricklen Anderson <BAnderson@PresiNET.com>
2005-07-22 19:56       ` David Hofmann <mor4321@hotmail.com>
2005-07-22 19:33   ` Jaime Casanova <systemguards@gmail.com>
2005-07-22 19:35     ` Bricklen Anderson <BAnderson@PresiNET.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