RE: Re: [Pljava-dev] PLJAVA Trigger Function more arguments

From: dgovoni at metadapt(dot)com (Darren Govoni)
To:
Subject: RE: Re: [Pljava-dev] PLJAVA Trigger Function more arguments
Date: 2005-11-02 15:01:09
Message-ID: 200511021501.jA2F19up007563@mmm711.vwh1.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

Could it be he wants to do a join across his 'elementos_intalacion_monitorizar' and 'configuration' tables and if IP address in configuration table has changed then select it and send code/values entering on the trigger for table 'elementos_intalacion_monitorizar' to that IP address.

Perhaps its just a matter of constructing a SQL statement that selects from another table (or possibly joins) inside the trigger. I too new to PLJAVA to know exactly how to do that.

Darren

>----- ------- Original Message ------- -----
>From: thomas at tada.se
>To: ilazaro at tekniker.es
>Sent: Wed, 02 Nov 2005 15:31:33
>
>Ignacio L?zaro wrote:
>> The concepts of 'old' and 'new' row is clear for
>me, my open question is:
>>
>> Is there another way of executing a java class
>from PostgreSQL trigger or function different than
>the following?
>>
>Please write the SQL that you envision for your use
>case. I don't
>understand what it is you're after. PL/Java will
>support whatever SQL
>PostgreSQL itself has support for.
>
>If you want to do what you just wrote, i.e 'After
>one UPDATE of this
>table I want send a UDP message to a port of a IP
>with the code and
>value modified (only if the value has changed)',
>then the 'new' row is
>sufficient. It contains the modified values of the
>code and value
>columns. If you want to check if the values have
>changed, you need to
>compare with the values of the 'old' row.
>
>Regards,
>Thomas Hallgren
>
>>
>>> CREATE TRIGGER
>tu_elementos_instalacion_monitorizar_tr
>>> AFTER UPDATE
>>> ON elementos_instalacion_monitorizar
>>> FOR EACH ROW
>>> EXECUTE PROCEDURE sendudpmessagetr('valor');
>>>
>>> CREATE OR REPLACE FUNCTION sendudpmessagetr()
>>> RETURNS "trigger" AS
>>> 'tekniker.udpip.SendUdpMessage.sendudpmessagetr'
>>> LANGUAGE 'javau' VOLATILE;
>>> ALTER FUNCTION sendudpmessagetr() OWNER TO
>optemi;
>>>
>>
>>
>> Regards
>> Nacho
>>
>> -----Mensaje original-----
>> De: Thomas Hallgren [mailto:thomas at tada.se]
>> Enviado el: mi?rcoles, 02 de noviembre de 2005
>15:15
>> Para: Ignacio L?zaro
>> CC: pljava-dev at gborg.postgresql.org
>> Asunto: Re: [Pljava-dev] PLJAVA Trigger Function
>more arguments
>>
>>
>> Ignacio L?zaro wrote:
>>
>>> Hello
>>>
>>> I have the table
>'elementos_intalacion_monitorizar' with the fields
>'value' and 'code'
>>> After one UPDATE of this table I want send a UDP
>message to a port of a IP with the code and value
>modified (only if the value has changed)
>>>
>>> I have a java class to send a UDP message and
>the required parameters are IP, port and
>code&value. IP and port are defined in a table
>named configuration
>>>
>>> So what I need, is to define a trigger that
>>> 1- check if the value of the code has really
>changed
>>> 2- get the ip and port from configuration table
>>> 3- execute the java class that send the UDP
>message with the required values
>>>
>>> What I have done
>>> 1- I have installed in postgreSQL the java class
>>> 2- I have defined the TRIGGER and FUNCTION
>explained before, but as I can understand with your
>last message and for my tests is that it is not
>possible get dinamically from a table the ip and
>port values inside the definition of the trigger
>>>
>>> My question at this stage : is there another way
>of executing a java class from PostgreSQL trigger
>or function?
>>>
>>>
>>>
>> A trigger has a concept of an 'old' and a 'new'
>row. What you're after
>> is the 'new' row, i.e.
>>
>> ResultSet newRow = td.getNew();
>> String value = newRow.getString("value");
>> String code = newRow.getString("code");
>>
>> Regards,
>> Thomas Hallgren
>>
>>
>
>_______________________________________________
>Pljava-dev mailing list
>Pljava-dev at gborg.postgresql.org
>http://gborg.postgresql.org/mailman/listinfo/pljava
>-dev

Browse pljava-dev by date

  From Date Subject
Next Message Marek Lewczuk 2005-11-08 11:34:01 [Pljava-dev] PostgreSQL 8.1 released
Previous Message Rakesh Vidyadharan 2005-11-02 14:39:59 [Pljava-dev] PLJAVA Trigger Function more arguments