pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
NOTIFY "string" from rule
2+ messages / 2 participants
[nested] [flat]

* NOTIFY "string" from rule
@ 2001-06-22 19:18 Jeff Boes <jboes@nexcerpt.com>
  2001-06-29 14:46 ` Re: NOTIFY "string" from rule Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Jeff Boes @ 2001-06-22 19:18 UTC (permalink / raw)
  To: pgsql-sql

Say my table looks like:

CREATE TABLE foo(status char(5), name char(5));

and I want to have a rule that does this:

CREATE RULE nf_foo AS
ON INSERT TO foo DO
NOTIFY new.status || '_' || new.name;

Any hints? My first attempt was to write a function:

CREATE FUNCTION bar(foo) RETURNS TEXT AS
'SELECT $1.status || ''_'' || $1.name;'
LANGUAGE 'sql';

and then change the last line of the rule to

NOTIFY bar(new);

but no luck. I would like to avoid writing a bunch of rules to process
each combination of 'status' and 'name' (at least they're each a limited
set!).


-- 
Jeff Boes                                             vox 616.226.9550
Database Engineer                                     fax 616.349.9076
Nexcerpt, Inc.                                      jboes@nexcerpt.com



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

* Re: NOTIFY "string" from rule
  2001-06-22 19:18 NOTIFY "string" from rule Jeff Boes <jboes@nexcerpt.com>
@ 2001-06-29 14:46 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2001-06-29 14:46 UTC (permalink / raw)
  To: Jeff Boes <jboes@nexcerpt.com>; +Cc: pgsql-sql

"Jeff Boes" <jboes@nexcerpt.com> writes:
> CREATE FUNCTION bar(foo) RETURNS TEXT AS
> 'SELECT $1.status || ''_'' || $1.name;'
> LANGUAGE 'sql';
> and then change the last line of the rule to
> NOTIFY bar(new);
> but no luck.

AFAIK the only way to do NOTIFY with a computed name is to write a
function in plpgsql or pltcl that computes a string 'NOTIFY whatever'
and then EXECUTEs that string.  There's no equivalent functionality
in SQL-language functions.

			regards, tom lane



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


end of thread, other threads:[~2001-06-29 14:46 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-06-22 19:18 NOTIFY "string" from rule Jeff Boes <jboes@nexcerpt.com>
2001-06-29 14:46 ` Tom Lane <tgl@sss.pgh.pa.us>

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