Notify rule
Hi!
I trying to create rule for update notifing:
CREATE OR REPLACE RULE "ttt_NotifyU" AS
ON UPDATE TO "ttt" DO
NOTIFY "ttt", '88';
this work.
But this
CREATE OR REPLACE RULE "ttt_NotifyU" AS
ON UPDATE TO "ttt" DO
NOTIFY "ttt", NEW."id";
don't (syntax error),
NOTIFY "ttt", CAST(NEW."id" as text)
too.
Q: How can I send tuple id (integer primary key) via notify using Rule?
Target is erasing deprecated tuples from application's cache.
<mailto:ivan_14_32@mail.ru>
ivan_14_32 <ivan_14_32@mail.ru> writes:
Q: How can I send tuple id (integer primary key) via notify using Rule?
You can't --- NOTIFY doesn't take variables in its parameters.
(That's a general property of utility commands, not just NOTIFY.)
Use the pg_notify() function, instead.
regards, tom lane
On Tue, Feb 22, 2011 at 1:03 AM, ivan_14_32 <ivan_14_32@mail.ru> wrote:
Hi!
I trying to create rule for update notifing:CREATE OR REPLACE RULE "ttt_NotifyU" AS
ON UPDATE TO "ttt" DO
NOTIFY "ttt", '88';
this work.But this
CREATE OR REPLACE RULE "ttt_NotifyU" AS
ON UPDATE TO "ttt" DO
NOTIFY "ttt", NEW."id";
don't (syntax error),
NOTIFY "ttt", CAST(NEW."id" as text)
too.Q: How can I send tuple id (integer primary key) via notify using Rule?
Target is erasing deprecated tuples from application's cache.
why use a rule here and not a trigger? triggers might be a bit more
verbose to right but explicit rules have and endless list of gotchas
and should be avoided unless you have a really good reason not to.
merlin
On Tue, Feb 22, 2011 at 1:03 AM, ivan_14_32 <ivan_14_32@mail.ru> wrote:
Hi!
I trying to create rule for update notifing:CREATE OR REPLACE RULE "ttt_NotifyU" AS
ON UPDATE TO "ttt" DO
NOTIFY "ttt", '88';
this work.But this
CREATE OR REPLACE RULE "ttt_NotifyU" AS
ON UPDATE TO "ttt" DO
NOTIFY "ttt", NEW."id";
don't (syntax error),
NOTIFY "ttt", CAST(NEW."id" as text)
too.Q: How can I send tuple id (integer primary key) via notify using Rule?
Target is erasing deprecated tuples from application's cache.
Well, that second argument to NOTIFY must be a literal. If you need to notify with a dynamic value, then you need to use the pg_notify function instead--regardless of whether you use a rule or a trigger.
--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice