On Fri, Jan 04, 2002 at 01:54:51PM -0500, Aaron Held wrote:
> I am trying to get a Postgres notification event heard in webware and
> having problems with what should be simple PG code.
>
> I'm trying to link a notify to a trigger, but I cannot seem to get notify
> working in a function. I only have C or SQL as a lang in the server, I
> do not have PL/pgSQL installed on this server.
>
> Should something as simple as
> create function wc_send_notify()
> return int4
> AS '
> notify wc_configuration_changed;
> select 1;
> ' language 'SQL';
Should be "returns", not "return". Otherwise, the function works for me:
pgnotify_test=> create function test_notify()
pgnotify_test-> returns int4
pgnotify_test-> as 'notify wc_config; select 1'
pgnotify_test-> language 'sql';
CREATE
pgnotify_test=> listen wc_config;
LISTEN
pgnotify_test=> select test_notify();
test_notify
-------------
1
(1 row)
Asynchronous NOTIFY 'wc_config' from backend with pid '571' received.
However, you can't use the function in a trigger because trigger functions
must return "opaque", and you can't create functions that return opaque in
language 'sql':
pgnotify_test=> create table test (id int primary key);
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index 'test_pkey' for table
'test'
CREATE
pgnotify_test=> create trigger boom
pgnotify_test-> after insert
pgnotify_test-> on test
pgnotify_test-> for each row
pgnotify_test-> execute procedure test_notify();
ERROR: CreateTrigger: function test_notify() must return OPAQUE
pgnotify_test=> drop function test_notify();
DROP
pgnotify_test=> create function test_notify()
pgnotify_test-> returns opaque
pgnotify_test-> as 'notify wc_config; select 1'
pgnotify_test-> language 'sql';
ERROR: ProcedureCreate: sql functions cannot return type "opaque"
--
Ng Pheng Siong <[EMAIL PROTECTED]> * http://www.netmemetic.com
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss