I have successfully connected to a table on the DB2 platform, however, I am told that a Data Area is not really a table.
They use a Data Area to write to when a job ends to control if it’s safe to run the next job. They’d like to implement the same type of control, which means I need to read the Data Area to check the posted message (which is only text).
It resides in the same library as the other table I’m connecting to and the username used is unrestricted in that library, but when I try to read the DataArea, I get a “Metadata object ‘FORECAST’ does not exist” error.
Here’s the code I used (I know it’s sloppy, it’s test code and I’m quite new to the lsx object model)
On Error Goto Handler
Dim agentLog As New NotesLog("Agent log")
Call agentLog.OpenAgentLog
Call agentLog.LogAction("Start Import procedure")
Dim session As New LCSession
Dim ns As New NotesSession
Dim ndb As notesDatabase
Set ndb = ns.CurrentDatabase
session.ClearStatus
Dim src As New LCConnection ("db2")
src.Database = "********"
src.UserID = "*****"
src.Password = "******"
src.Connect
Call agentLog.LogAction("Declare fields")
Dim keys As New LCFieldList
Dim datarea As New LCField (LCTYPE_TEXT, 1)
Dim field As LCField
src.Metadata = "LIBNAME.FORECAST"
Set field = Nothing
Dim fields As New LCFieldList
Dim count As Integer
count=src.Select (Nothing, 1,fields)
Print count
If count = 0 Then
Print "The resultset is empty"
Else
Print "There are " & count & " records which match the selection criteria."
End If
Dim counter As Integer
count = src.Fetch (fields, 1, 1)
While count <> 0
Set datarea = fields.GetField(1)
Dim nd As New NotesDocument(ndb)
nd.Form = "DataArea"
nd.DataArea = datarea.text(0)
Call nd.Save(True, False)
count = src.Fetch (fields, 1, 1)
counter = counter + 1
Wend
Print " record #" & Cstr(counter)
Call agentLog.LogAction("Done running agent")
Call agentLog.Close
Exit Sub
Handler:
If (Session.Status <> LCSUCCESS) Then
Print session.GetStatusText
Else
Print " The following LotusScript Error has occurred" & Error$ & "in object: " & Lsi_info(2)
End If
Call agentLog.LogAction("Agent terminated abnormally.")
Call agentLog.Close