Subject: How do I retrieve PACKED and ZONED data types with the DB2 lsx libraries?
Luc, It’s been a couple of years since I built an app that pulled data from the AS/400, but I’ll try to help. Zoned and Packed fields are both numeric fields on the 400. So we handled them the exact same way when bringing them down into Notes. There might have been better ways to accomplish this, but basically we would create the new lcsession, lcconnection and lcfieldlist. Then we would build a query string and execute the query, pulling the results into the fieldlist. One by one, we would then just fetch each value in the fieldlist into the matching Notes field - regardless of numeric type. I’m not sure that’s the best or most elegant way, but it got the job done.
Updating data back up to the 400 is really where you have to worry about making conversions for data types. But if you’re just fetching, it shouldn’t be a problem.
In the code below, BMWLCD is a char field on the 400 and text in notes. BMFLDT is an ISO date field on the 400 (character) and a date field in notes. And BMCANR is a zoned numeric on the 400 and a number field in notes. So you can see they all work the same way.
HTH
Jackie
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
Dim session As NotesSession
Set session = New notesSession
Dim db As notesdatabase
Set db = session.currentdatabase
Dim doc As NotesDocument
Dim lcsession As New lcsession
lcsession.clearstatus
Dim fldlst As LCfieldlist
Dim fld As lcfield
Dim src As New lcconnection(“DB2”)
Dim count As Integer
Dim Query As String
Dim profiledoc As notesdocument
Set profiledoc =db.Getprofiledocument(“Profile”)
src.database = profiledoc.database(0)
src.userid = profiledoc.userid(0)
src.password = profiledoc.password(0)
src.connect
If lcsession.status = LCSUCCESS Then Print "CONNECTED SUCCESSFULLY to " & profiledoc.database(0)
query = "Select * From " & profiledoc.library(0) & “.” & "BLKMST where BMWLCD = " & “'” & uidoc.fieldgettext(“BMWLCD”) & “'”
count = 0
Set fldlst = New LCfieldlist
Call src.execute(query,fldlst)
Do While src.fetch(fldlst) > 0
count = count + 1
Set doc = New NotesDocument(db)
doc.form = "BM"
doc.BMWLCD = fldlst.BMWLCD(0)
doc.BMFLDT = fldlst.BMFLDT(0)
doc.BMCANR = fldlst.BMCANR(0)
doc.BMWYCD = fldlst.BMWYCD(0)
Call doc.save(True, False)
Loop
'messagebox “Retrieved " & Cstr(count) & " Records”
Call uidoc.refresh(True)