B4J Question B4J - How to subscribe to Firebird 'event' ?

amorosik

Expert
Licensed User
The Firebird Sql database has a feature that allows the db server to communicate with the clients that have subscribed to the desired events.
It is necessary to create a trigger like:
------------------------------------------
CREATE OR ALTER TRIGGER TR2 FOR PRODUCTS
ACTIVE AFTER UPDATE POSITION 0 AS BEGIN
IF (new.PRICE <> old.PRICE) THEN POST_EVENT 'price_changed';
END
------------------------------------------


This feature is very useful in applications such as chat or similar where the client part must react quickly to changes that occur in the database
It would be very interesting to have this functionality also for B4X programs, and therefore the question is:
how to 'subscribe' a Firebird Sql event from B4X code?
 

amorosik

Expert
Licensed User
Not via jdbc, but using db driver for dot net (second link) is possible capture the desired events
With this code it is possible to see the lines appear in correspondence of the changes defined in the trigger inside the database:

Firebird Events Capture:
string ConnectionString = "User=utente;Password=password;DataSource=localhost;Database=c:\pippo.fdb;Charset=NONE;"
FbConnection FbConn = new FbConnection(ConnectionString);
FbConn.Open();
FbRemoteEvent revent = new FbRemoteEvent(FbConn);
FbRemoteEvent remote_event = new FbRemoteEvent(FbConn);
remote_event.AddEvents(new string[] { "Event_Name" });
remote_event.RemoteEventCounts += new FbRemoteEventEventHandler(Evento_Avviato);
remote_event.QueueEvents();
Console.ReadLine();
FbConn.Close();
+
 static void Evento_Avviato(object sender, FbRemoteEventEventArgs args)
 { Console.WriteLine("Event {0} has {1} counts.", args.Name, args.Counts); }

By following this code fragment, is there the possibility to use the driver (Ado Net Firebird data provider), to capture the events defined in the database?
 
Upvote 0

amorosik

Expert
Licensed User
I see now that a jdbc driver is available for Firebird, they call it Jaybird
For Jaybird 4.0, the latest version, extensive documentation is available
Section 8.3 describes how to subscribe to an event present in Firebird, with a code example in section 8.3.1


Could you help me convert the code shown in section 8.3.1 as B4J code?
 
Upvote 0

amorosik

Expert
Licensed User
I am a super novice, currently I am not able to write a library for B4X environment
But this is extremely important and would allow to have an effective pro-active database, able to react the management procedures to the occurrence of some changes in the data
And therefore I postpone writing the library as soon as possible
As soon as I can understand exactly what it means to 'write a library' I will try to achieve what is described
 
Upvote 0

jorge basualdo

New Member
Licensed User

Could you resolve it? I need to do almost the same.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…