agora inbox for pljava-dev@postgresql.org  
help / color / mirror / Atom feed
[Pljava-dev] PLJAVA Trigger Function more arguments
10+ messages / 0 participants
[nested] [flat]

* [Pljava-dev] PLJAVA Trigger Function more arguments
@ 2005-11-02 11:49 
  2005-11-02 13:17 ` [Pljava-dev] PLJAVA Trigger Function more arguments 
  0 siblings, 1 reply; 10+ messages in thread

From:  @ 2005-11-02 11:49 UTC (permalink / raw)

Hello 

I have a question, I have defined a java trigger and I want send from 
PostgreSQL more arguments than the TriggerData object

I have the following code

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;

public static void sendudpmessagetr(TriggerData td) throws SQLException{...}   

My question is that if is it possible define 

public static void sendudpmessagetr(TriggerData td, String str1, String str2) 
throws SQLException{...}  

Or if it is possible to define inside the TriggerData more arguments because I 
have see in documentation that is avaliable the getArguments() method, but I 
don?t know how define these new arguments in the TRIGGER function

Thanks in advance for your help

Nacho







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

* [Pljava-dev] PLJAVA Trigger Function more arguments
  2005-11-02 11:49 [Pljava-dev] PLJAVA Trigger Function more arguments 
@ 2005-11-02 13:17 ` 
  0 siblings, 0 replies; 10+ messages in thread

From:  @ 2005-11-02 13:17 UTC (permalink / raw)

Nacho wrote:
> Hello 
>
> I have a question, I have defined a java trigger and I want send from 
> PostgreSQL more arguments than the TriggerData object
>
> I have the following code
>
> 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;
>
> public static void sendudpmessagetr(TriggerData td) throws SQLException{...}   
>
> My question is that if is it possible define 
>
> public static void sendudpmessagetr(TriggerData td, String str1, String str2) 
> throws SQLException{...}  
>
> Or if it is possible to define inside the TriggerData more arguments because I 
> have see in documentation that is avaliable the getArguments() method, but I 
> don?t know how define these new arguments in the TRIGGER function
>   
I'm not sure I understand the question. The TriggerData.getArguments() 
will return an array of strings. There's no limit to the number of 
strings. These strings are the arguments that you define in your EXECUTE 
PROCEDURE xxx(arg1, arg2, arg3). In your case you can do

String[] args = td.getArguments();
if(td[0].equals("valor")) { ... }

But perhaps you're after something completely different?

Regards,
Thomas Hallgren





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

* [Pljava-dev] PLJAVA Trigger Function more arguments
@ 2005-11-02 13:34 
  2005-11-02 13:50 ` [Pljava-dev] PLJAVA Trigger Function more arguments 
  0 siblings, 1 reply; 10+ messages in thread

From:  @ 2005-11-02 13:34 UTC (permalink / raw)

Hello Thomas

My intention is define a trigger in a table, that execute a java method defined in a java class 'tekniker.udpip.SendUdpMessage.sendudpmessagetr'

The way in which I have defined the trigger is with the TRIGGER tu_elementos_instalacion_monitorizar_tr and the FUNCTION sendudpmessagetr (that is associated to the java class). 

I need to pass to the method of the java class 2 additional arguments ( stored in a table of the database ) but I don?t know which is the way to define this in the TRIGGER tu_elementos_instalacion_monitorizar_tr or in the FUNCTION sendudpmessagetr, perhaps there is other way more efficient to do 

Probably I can define this

CREATE TRIGGER tu_elementos_instalacion_monitorizar_tr
   AFTER UPDATE
   ON elementos_instalacion_monitorizar
   FOR EACH ROW
   EXECUTE PROCEDURE sendudpmessagetr(varchar,varchar);

but how can I define the values for both varchar arguments

Best Regards
Nacho

-----Mensaje original-----
De: Thomas Hallgren [mailto:thomas at tada.se]
Enviado el: mi?rcoles, 02 de noviembre de 2005 14:18
Para: Ignacio L?zaro
CC: pljava-dev at gborg.postgresql.org
Asunto: Re: [Pljava-dev] PLJAVA Trigger Function more arguments


Nacho wrote:
> Hello 
>
> I have a question, I have defined a java trigger and I want send from 
> PostgreSQL more arguments than the TriggerData object
>
> I have the following code
>
> 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;
>
> public static void sendudpmessagetr(TriggerData td) throws SQLException{...}   
>
> My question is that if is it possible define 
>
> public static void sendudpmessagetr(TriggerData td, String str1, String str2) 
> throws SQLException{...}  
>
> Or if it is possible to define inside the TriggerData more arguments because I 
> have see in documentation that is avaliable the getArguments() method, but I 
> don?t know how define these new arguments in the TRIGGER function
>   
I'm not sure I understand the question. The TriggerData.getArguments() 
will return an array of strings. There's no limit to the number of 
strings. These strings are the arguments that you define in your EXECUTE 
PROCEDURE xxx(arg1, arg2, arg3). In your case you can do

String[] args = td.getArguments();
if(td[0].equals("valor")) { ... }

But perhaps you're after something completely different?

Regards,
Thomas Hallgren





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

* [Pljava-dev] PLJAVA Trigger Function more arguments
  2005-11-02 13:34 [Pljava-dev] PLJAVA Trigger Function more arguments 
@ 2005-11-02 13:50 ` 
  0 siblings, 0 replies; 10+ messages in thread

From:  @ 2005-11-02 13:50 UTC (permalink / raw)

Ignacio L?zaro wrote:
> Hello Thomas
>
> My intention is define a trigger in a table, that execute a java method defined in a java class 'tekniker.udpip.SendUdpMessage.sendudpmessagetr'
>
> The way in which I have defined the trigger is with the TRIGGER tu_elementos_instalacion_monitorizar_tr and the FUNCTION sendudpmessagetr (that is associated to the java class). 
>
> I need to pass to the method of the java class 2 additional arguments ( stored in a table of the database ) but I don?t know which is the way to define this in the TRIGGER tu_elementos_instalacion_monitorizar_tr or in the FUNCTION sendudpmessagetr, perhaps there is other way more efficient to do 
>
> Probably I can define this
>
> CREATE TRIGGER tu_elementos_instalacion_monitorizar_tr
>    AFTER UPDATE
>    ON elementos_instalacion_monitorizar
>    FOR EACH ROW
>    EXECUTE PROCEDURE sendudpmessagetr(varchar,varchar);
>
> but how can I define the values for both varchar arguments
>   
I don't understand.  Let's say you issue the following statement:

UPDATE elementos_instalacion_monitorizar SET xyz = 'abc' WHERE foo = 'bar';

This will trigger a call to your trigger. How did you plan to select 
stuff from 'a table in the database' and pass parameters at that point? 
PostgreSQL allows you to set fixed values which makes sense. Different 
CREATE TRIGGER can appoint the same PROCEDURE but use different fixed 
arguments.

Can you give me an example on how you would like to pass your values? 
Just use SQL and forget about PL/Java for a moment.

Regards,
Thomas Hallgren





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

* [Pljava-dev] PLJAVA Trigger Function more arguments
@ 2005-11-02 14:03 
  2005-11-02 14:15 ` [Pljava-dev] PLJAVA Trigger Function more arguments 
  0 siblings, 1 reply; 10+ messages in thread

From:  @ 2005-11-02 14:03 UTC (permalink / raw)

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?

Many thanks for your comments
Nacho


-----Mensaje original-----
De: Thomas Hallgren [mailto:thomas at tada.se]
Enviado el: mi?rcoles, 02 de noviembre de 2005 14:50
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 Thomas
>
> My intention is define a trigger in a table, that execute a java method defined in a java class 'tekniker.udpip.SendUdpMessage.sendudpmessagetr'
>
> The way in which I have defined the trigger is with the TRIGGER tu_elementos_instalacion_monitorizar_tr and the FUNCTION sendudpmessagetr (that is associated to the java class). 
>
> I need to pass to the method of the java class 2 additional arguments ( stored in a table of the database ) but I don?t know which is the way to define this in the TRIGGER tu_elementos_instalacion_monitorizar_tr or in the FUNCTION sendudpmessagetr, perhaps there is other way more efficient to do 
>
> Probably I can define this
>
> CREATE TRIGGER tu_elementos_instalacion_monitorizar_tr
>    AFTER UPDATE
>    ON elementos_instalacion_monitorizar
>    FOR EACH ROW
>    EXECUTE PROCEDURE sendudpmessagetr(varchar,varchar);
>
> but how can I define the values for both varchar arguments
>   
I don't understand.  Let's say you issue the following statement:

UPDATE elementos_instalacion_monitorizar SET xyz = 'abc' WHERE foo = 'bar';

This will trigger a call to your trigger. How did you plan to select 
stuff from 'a table in the database' and pass parameters at that point? 
PostgreSQL allows you to set fixed values which makes sense. Different 
CREATE TRIGGER can appoint the same PROCEDURE but use different fixed 
arguments.

Can you give me an example on how you would like to pass your values? 
Just use SQL and forget about PL/Java for a moment.

Regards,
Thomas Hallgren





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

* [Pljava-dev] PLJAVA Trigger Function more arguments
  2005-11-02 14:03 [Pljava-dev] PLJAVA Trigger Function more arguments 
@ 2005-11-02 14:15 ` 
  0 siblings, 0 replies; 10+ messages in thread

From:  @ 2005-11-02 14:15 UTC (permalink / raw)

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





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

* [Pljava-dev] PLJAVA Trigger Function more arguments
@ 2005-11-02 14:21 
  2005-11-02 14:31 ` [Pljava-dev] PLJAVA Trigger Function more arguments 
  0 siblings, 1 reply; 10+ messages in thread

From:  @ 2005-11-02 14:21 UTC (permalink / raw)

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?

> 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





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

* [Pljava-dev] PLJAVA Trigger Function more arguments
  2005-11-02 14:21 [Pljava-dev] PLJAVA Trigger Function more arguments 
@ 2005-11-02 14:31 ` 
  0 siblings, 0 replies; 10+ messages in thread

From:  @ 2005-11-02 14:31 UTC (permalink / raw)

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
>
>   





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

* [Pljava-dev] PLJAVA Trigger Function more arguments
@ 2005-11-02 14:39 
  0 siblings, 0 replies; 10+ messages in thread

From:  @ 2005-11-02 14:39 UTC (permalink / raw)


On 2 Nov 2005, at 08:30, Ignacio L?zaro wrote:

>> Do you mean execute a SQL statement from within a Trigger?  That
>> should be possible using the usual JDBC techniques.  The trigger body
>> can execute any standard Java code, provided that the TriggerData can
>> supply you with the information you need to execute the associated  
>> code.
>>
>
> I am not very sure, you mean that the trigger body is inside  
> postgreSQL or inside the java class??
> do you have any example ?
> Regards
> Nacho

The following is the only time I have done a trigger in PL/Java:

   /**
    * The trigger to be invoked when deleting a <code>Group</code>
    * record.  All <code>User</code> records that are exclusively
    * associated with the <code>Group</code> specified will be
    * deleted.
    *
    * @see UserFunctions#deleteByGroup
    * @param triggerData The PostgreSQL provided interface with
    *   data pertaining to the old or new records as appropriate
    * @throws SQLException If errors are encountered while deleting
    *   the User records.  Also thrown if the trigger is fired by
    *   a <code>non-delete</code> operation on the table.
    */
   public static void deleteTrigger( TriggerData triggerData )
     throws SQLException
   {
     if( triggerData.isFiredByDelete() &&
         triggerData.isFiredForEachRow() )
     {
       ResultSet resultSet = null;
       try
       {
         resultSet = triggerData.getOld();
         resultSet.next();
         UserFunctions.deleteByGroup( resultSet.getInt( "groupId" ) );
       }
       finally
       {
         CloseResources.close( resultSet );
       }
     }
     else
     {
       throw new TriggerException( triggerData,
           "Can process only DELETE events on each row" );
     }
   }

The UserFunctions.deleteByGroup is defined as:

   /**
    * Delete all the <code>Users</code> who are solely associated with
    * the specified <code>Group</code>.
    *
    * @param groupId The primary key value of the group whose exclusive
    *   users are to be deleted.
    * @return boolean - Returns <code>false</code> to indicate that the
    *   executing the statement returns nothing.
    * @throws SQLException If errors are encountered while deleting
    *   the users.
    */
   public static final boolean deleteByGroup( int groupId )
     throws SQLException
   {
     Connection connection = null;
     PreparedStatement statement = null;

     try
     {
       connection = ConnectionFactory.getConnection();
       statement = connection.prepareStatement( deleteByGroup );
       statement.setInt( 1, groupId );
       statement.setInt( 2, groupId );
       statement.execute();
     }
     finally
     {
       CloseResources.close( statement );
       CloseResources.close( connection );
     }

     return false;
   }




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

*  RE: Re: [Pljava-dev] PLJAVA Trigger Function more arguments
@ 2005-11-02 15:01 
  0 siblings, 0 replies; 10+ messages in thread

From:  @ 2005-11-02 15:01 UTC (permalink / raw)

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




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


end of thread, other threads:[~2005-11-02 15:01 UTC | newest]

Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-11-02 11:49 [Pljava-dev] PLJAVA Trigger Function more arguments 
2005-11-02 13:17 ` 
2005-11-02 13:34 [Pljava-dev] PLJAVA Trigger Function more arguments 
2005-11-02 13:50 ` 
2005-11-02 14:03 [Pljava-dev] PLJAVA Trigger Function more arguments 
2005-11-02 14:15 ` 
2005-11-02 14:21 [Pljava-dev] PLJAVA Trigger Function more arguments 
2005-11-02 14:31 ` 
2005-11-02 14:39 [Pljava-dev] PLJAVA Trigger Function more arguments 
2005-11-02 15:01  RE: Re: [Pljava-dev] PLJAVA Trigger Function more arguments 

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox