Re: Listen and Notify

From: Mark Morgan Lloyd <markMLl(dot)pgsql-general(at)telemetry(dot)co(dot)uk>
To: pgsql-general(at)PostgreSQL(dot)org
Subject: Re: Listen and Notify
Date: 2012-05-01 12:51:43
Message-ID: jnom90$tp9$1@pye-srv-01.telemetry.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Merlin Moncure wrote:
> On Mon, Apr 30, 2012 at 1:47 AM, Alexander Reichstadt <lxr(at)mac(dot)com> wrote:
>> Hi,
>>
>> From the documentation I was able to build a trigger firing upon deletion of a record a function that delivers tablename_operation as a notification one needs to subscribe to. So in terminal I can say LISTEN persons_delete and instantly will receive
>>
>> Asynchronous notification "persons_delete" received from server process with PID 54790.
>>
>> if there was a delete. But what I don't fully understand is how to do this with PQnotifies. Following the docu I get no notifications even though I subscribe to them after successfully connecting to the server the same way I do using terminal.
>>
>> Googling didn't give me examples I was able to use. Please, can someone help?
>
> I'm suspecting operator error because using PQnotifies is exactly what
> psql does. Maybe you could post a small test program? Are you using
> a mixed case notification name?

Works here in a Pascal program built using Lazarus. You /must/ however,
ensure that the session requesting the notification is kept active and
is the one that's regularly checked, it's easy to lose track of this in
a development framework which isolates you from the low-level handles etc.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Schade, Jeffrey 2012-05-01 12:58:38 Table / View Security Report
Previous Message Matthew Churcher 2012-05-01 12:06:56 Re: Having trouble with pg_dumpall -o