Sub Initialize
Dim notessession As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim view As NotesView
Dim doc As NotesDocument
Dim docfld As NotesItem
Dim session As New LCSession
Dim src As New LCConnection ("sybase")
Dim fldLst As LCFieldList 'result set provided by stored proc
Dim keyLst As New LCFieldList 'input to stored proc
Dim fld As LCField
Dim notesServer As String
Dim notesDb As String
Dim viewName As String
Dim inputFieldName As String
'Set src attributes
src.Server = "SYBASESERVER"
src.Database = "SYBASEDBASE"
src.Userid = "SYBASEUSER"
src.Password = "SYBASEPW"
src.Procedure = "STOREDPROC"
'Connect to src
src.Connect
'Identify location of Notes Documents to update
'For this example, the doc resides within this db
notesServer = notessession.CurrentDatabase.Server
notesDb = notessession.CurrentDatabase.FilePath
viewName= "VIEWNAME"
inputFieldName="FIELDNAME
Requires Free Membership to View
Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.
PROVIDING INPUT PARAMETER TO SYBASE DB" Set db = notessession.GetDatabase(notesServer,notesDb) Set view = db.GetView( viewName) Set doc=view.GetFirstDocument Set fld = keyLst.Append(inputFieldName,LCTYPE_TEXT) While Not (doc Is Nothing) 'docfld is the field used on the Notes Document 'as an input to the stored procedure Set docfld=doc.GetFirstItem(inputFieldName) 'Get the field value from the Notes doc fld.text=docfld.Text fld.value=docfld.Text Set fldLst = New LCFieldList 'Call the stored procedure, provide it the input parameter, and get the result set If (src.Call (keyLst, 1, fldLst) = 0) Then 'If no result set, set the field to NULL doc.Comment = "" Else 'Process the result set - Concatenate text together 'The Getfield(3) returns the 3rd field in the result set While src.Fetch (fldLst, 1, 1) > 0 message = message & fldLst.Getfield(X).text(0) Wend doc.Comment = Cstr(message) End If Call doc.Save(False, True ) 'Get ready for next document Delete fldLst message = Null Set doc=view.GetNextDocument(doc) Wend src.Disconnect End Sub
This was first published in January 2002