Is it possible to read a Data Area on a DB2 platform (on iSeries) using the Lotusscript lsx libraries?

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

Subject: Is it possible to read a Data Area on a DB2 platform (on iSeries) using the Lotusscript lsx libraries?

there is another way, use a stored procedure.

http://publib.boulder.ibm.com/iseries/v5r2/ic2924/index.htm?info/sqlp/rbafymst02.htm

with a stored procedure of external type, your collegue can write a program in any HLL such as Cobol or RPG or whatever he likes to read the data area and pass back the fields as output parameters.

the stored procedure needs to be registered in the database via iseries navigator or the create procedure SQL command.

I don’t know how, but I do know that you can call a stored procedure from LS lsx and receive the fields returned as output parameters.

no java and no modification to existing programs

Subject: Is it possible to read a Data Area on a DB2 platform (on iSeries) using the Lotusscript lsx libraries?

It’s correct. A data area is not a table at all. Consider it an object that contains one text string. Trying to access it like you do will be refused by the operating system.

I never used it myself, but IBM has a Java based toolbox that can be used to access different kinds of objects on iSeries. One of the supported objects is a Data area.

You can find information on the toolbox here :

http://www-1.ibm.com/servers/eserver/iseries/toolbox/overview.htm#what

An easy workaround would be that the application that writes to the data area, writes to a database file that contains one record. Changing the application like that would only take a few minutes

Subject: RE: Is it possible to read a Data Area on a DB2 platform (on iSeries) using the Lotusscript lsx libraries?

Thank you for taking time to write your answer.

I definately want to avoid combining Java in this … it will be complex enough already :slight_smile:

I will ask the programmer to modify the programs to accomodate writing to a table with only one row like you suggested.

Luc