Example of using LS:DO to connect Domino to other systems
Here's another forgotten "gem". T'other night I was talking a friend through configuring Domino on Linux (getting inbound and outbound mail routing as desired, setting up Internet site documents to route users to different databases depending on hostname, etc.), and he brought up something experimental I'd written for him a couple years ago but we'd never gotten around to implementing: an agent that parsed incoming email and updated records in a MySQL database based on the email content. At the time, I considered the LS:DO classes to be kind of a pain in the ass to use, so I encapsulated some of their basic functionality into some wrapper objects, but had forgotten all about that until he mentioned it again.
I wasn't even sure I still had that old code, but I found it on the SD card in my Treo... so I threw together a quick CD Collection database that maps directly to the "cdcol" example database that's included with the default installation of XAMPP, and plugged in the LS:DO wrappers to allow synchronization between the two (for example, the QuerySave of the form automatically writes the document to MySQL - as an insert if it's a new document, otherwise as an update). Here are the highlights:
Let isNew = document.IsNewNote
Let title = document.GetItemValue("Title")(0)
Let artist = document.GetItemValue("Artist")(0)
Let cdYear = document.GetItemValue("Year")(0)
If isNew Then
Let id = Me.getNextId()
Call document.ReplaceItemValue("ID", id)
Call Me.getDSN().issueInsertStatement("cds", {'} & title & {','} & artist & {',} & cdYear & {,} & id)
Else
Let id = document.GetItemValue("ID")(0)
If (Me.getDSN().issueSelectStatement("cds", {id}, {id = } & id, "").numRows > 0) Then
Call Me.getDSN().issueUpdateStatement("cds", {titel = '} & title & {', interpret = '} & artist & {', jahr = } & cdYear, {id = } & id, "")
Else
Call Me.getDSN().issueInsertStatement("cds", {'} & title & {','} & artist & {',} & cdYear & {,} & id)
End If
End If
You can download the example database here.
Comments
Posted by Charles Robinson At 10:52:46 PM On 02/24/2008 | - Website - |
For real db access from LotusScript, you should really use the Lotus Connectors instead. The object model for those is no picnic either, but it does work, and it's supported. There's even a toolkit in case you want to write your own connector.
Posted by Bob Balaban At 10:37:11 PM On 02/24/2008 | - Website - |
Thanks for stretching the imagination.
Posted by Jack Dausman At 08:21:25 PM On 02/25/2008 | - Website - |