X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BCA02D1DD3B for ; Tue, 13 Jan 2004 21:36:47 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 44953-09 for ; Tue, 13 Jan 2004 17:36:18 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 37571D1DA9F for ; Tue, 13 Jan 2004 17:36:16 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i0DLaFU6007287 for ; Tue, 13 Jan 2004 21:36:15 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i0DLGlvG064192 for pgsql-sql@postgresql.org; Tue, 13 Jan 2004 21:16:47 GMT X-Abuse-Report: abuse@teranews.com Message-ID: <2d8491964a9d65324f083494a9f54f8b@news.teranews.com> Date: Tue, 13 Jan 2004 21:07:45 GMT Lines: 37 From: Jeff Boes Organization: Nexcerpt, Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20030925 X-Accept-Language: en-us, en MIME-Version: 1.0 X-Newsgroups: comp.databases.postgresql.sql Subject: Rule won't let me NOTIFY, no matter how hard I try Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/119 X-Sequence-Number: 16512 Here's the setup: I wanted to write a rule that would fire on an update to one table, and do an update to another table, followed by a notify. My first attempt wasn't acceptable to PG (7.3.4): create rule "my_rule" as on update to table_A where new.col_A != old.col_A do (update table_B ...; notify "my_signal"; ); ... because you can't have a "notify" statement in a rule that fires on update (only select, update, and delete, I guess). Second attempt was to "hide" the notify in a function: create function fn_notify(TEXT) returns VOID as ' execute ''notify " || $1 || "''; ' language 'plpgsql'; Oddly enough, this works IF and ONLY IF the rule "my_rule" fires and the internal update statement does not update any rows. If it actually updates a row, then I get this error: WARNING: plpgsql: ERROR during compile of fn_notify near line 5 ERROR: syntax error at or near "" What gives? Must I use a trigger to get around this? -- Jeff Boes vox 269.226.9550 ext 24 Database Engineer fax 269.349.9076 Nexcerpt, Inc. http://www.nexcerpt.com ...Nexcerpt... Extend your Expertise