Platforms to show: All Mac Windows Linux Cross-Platform

/SQL/SQLDatabaseMBS PostgreSQL Notify and Listen
Required plugins for this example: MBS SQL Plugin, MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /SQL/SQLDatabaseMBS PostgreSQL Notify and Listen
This example is the version from Wed, 3rd Mar 2015.
Project "SQLDatabaseMBS PostgreSQL Notify and Listen.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open() db = new mySQLDatabaseMBS // this is path for a Mac, your path will be different! dim libPath as string = "/Library/PostgreSQL/9.1/lib/libpq.5.4.dylib" db.Option(db.kOptionLibraryPostgreSQL) = libPath // connect to database // in this example it is Postr, // but can also be Sybase, Oracle, Informix, DB2 // SQLServer, InterBase, SQLBase and ODBC db.DatabaseName="PostgreSQL:,5432@postgres" db.UserName="postgres" db.Password="xxx" if db.Connect then // tell server to send notifications to us db.SQLExecute "LISTEN test;" // listen for notifications db.Listen else MsgBox db.ErrorMessage quit end if End EventHandler
Property db As SQLDatabaseMBS
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 mySQLDatabaseMBS Inherits SQLDatabaseMBS
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
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 db as database = app.db db.SQLExecute "NOTIFY test" 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
End Project

See also:

Feedback, Comments & Corrections

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

The biggest plugin in space...

MBS Xojo tutorial videos

Start Chat