List Method for LCFieldlist
This method retrieves information about one field in the fieldlist. By calling it repeatedly, you can iterate through the fields in the list.
Defined In
LCFieldlist
Syntax
flag = fldLst. List (position, destField, index, dataType, flags, fieldName)
Parameters
Parameter |
Description |
---|---|
position |
Long. Constant indicating whether to return the first or next field. The options are: LCLIST_FIRST -- Return the first property in the property list. LCLIST_NEXT -- Return the next property (or the first property if this is the first call to this function for this Connection). |
destField |
LCField. Output, optional. The field in the fieldlist. |
index |
Long. Output, optional. Index of destField in the fieldlist. This may not advance consecutively for fieldlists produced with LCFieldlist.Merge or LCFieldlist.MergeVirtual. |
dataType |
Long. Output, optional. Data type of destField. |
flags |
Long. Output, optional. Field flags of destField. Refer to the Field Class section for a description of the flags. |
fieldName |
String. Output, optional. The field name. Note: This
information is not also stored in destField. |
Example
Option Public
Uselsx "*lsxlc"
Sub Initialize
Dim connect As New LCConnection ("db2")
Dim FldLst As New LCFieldlist
Dim pos As Long
Dim dtype As Long
Dim flags As Long
Dim fieldname As String
REM this section assigns the appropriate properties to connect to DB2
connect.Database = "Gold"
connect.Userid = "JDoe"
connect.Password = "xyzzy"
connect.Metadata = "customer"
REM connect to DB2
connect.Connect
REM select the records in the table (just to get the field descriptions)
If (connect.Select (Nothing, 1, FldLst) = 0) Then
Print "The customer table was not found."
Else
Print "The table description is:"
pos = LCLIST_FIRST
While (FldLst.List (pos, , , dtype, flags, fieldname) = True)
Print " " + fieldname + " is type #" +_
Cstr(dtype) + " with flags " + Hex(flags)
pos = LCLIST_NEXT
Wend
End If
End Sub
Example Output
The table description is:
ACCOUNTMANAGER is type #1 with flags 2
CONTACTNAME is type #6 with flags 2
COMPANYNAME is type #6 with flags 2
COMPANYADDRESS is type #6 with flags 2
COMPANYCITY is type #6 with flags 2
COMPANYSTATE is type #6 with flags 2
COMPANYPHONE is type #6 with flags 2