Platforms to show: All Mac Windows Linux Cross-Platform

/SQL/PostgreSQL Notify and Listen


Required plugins for this example: MBS Util Plugin, MBS SQL Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /SQL/PostgreSQL Notify and Listen

This example is the version from Wed, 3rd Mar 2015.

Project "PostgreSQL Notify and Listen.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open() con = new mySQLConnectionMBS // this is path for a Mac, your path will be different! dim libPath as string = "/Library/PostgreSQL/9.1/lib/libpq.5.4.dylib" con.Option(con.kOptionLibraryPostgreSQL) = libPath dim server as string = "127.0.0.1,5432@postgres" con.Connect(server, "postgres", "xxx", SQLConnectionMBS.kPostgreSQLClient) // tell server to send notifications to us dim cmd as new SQLCommandMBS(con, "LISTEN test;") cmd.Execute // listen for notifications con.Listen End EventHandler
Property con As SQLConnectionMBS
End Class
Class Window1 Inherits Window
Control Listbox1 Inherits Listbox
ControlInstance Listbox1 Inherits Listbox
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() // send notification with name test dim cmd as new SQLCommandMBS(app.con, "NOTIFY test") cmd.Execute End EventHandler
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
EventHandler Sub Open() me.Text = "My Process ID: "+str(ProcessMBS.CurrentProcessID) End EventHandler
End Control
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Class mySQLConnectionMBS Inherits SQLConnectionMBS
EventHandler Sub PostgresNotification(NotificationName as string, PID as Integer, Extras as String) dim m as string = NotificationName if pid <> 0 then m = m + " (ProcessID: "+str(pid)+")" end if if Extras <> "" then m = m + " "+Extras end if window1.Listbox1.AddRow m End EventHandler
EventHandler Sub Trace(traceInfo as integer, SQL as string, Command as SQLCommandMBS) window1.Listbox1.AddRow "Trace: "+sql End EventHandler
End Class
End Project

See also:

The items on this page are in the following plugins: MBS SQL Plugin.


The biggest plugin in space...