Map Method for LCFieldlist
This method copies field references from one field list, into another field list. It's similar to the CopyRef method, except that you specify the names of fields you want to create new references to.
After you use Map, the source and destination lists will contain field references to (some of) the same LCField objects. No new LCField objects are created by this call.
Use this method for field mapping operations when the fieldnames are the same in source and target, but you need to change the order of the fields or you wish to exclude some fields. If the field names are not the same in source and target, use MapName.
Defined In
LCFieldlist
Syntax
Call destList. Map (baseFieldList, nameList)
Parameters
Parameter |
Description |
---|---|
srcList |
LCFieldlist. The fieldlist to map. |
nameList |
String. Comma-delimited names of fields from srcList in the new, remapped order. |
Usage Notes®
The value of destList can not be Nothing - there must already be an object there, preferably one just created with the New method. If the destList list already contains some fields, the Map method discards them.
Example
Option Public
Uselsx "*lsxlc"
Sub Initialize
Dim session As New LCSession
Dim srcCon As New LCConnection ("db2")
Dim fldLst As New LCFieldList
Dim fetchLst As New LCFieldList
Dim count As Long
Dim cname As LCField
Dim ccity As LCField
Dim cstate As LCField
' set the appropriate properties to connect to the data sources
srcCon.Database = "Gold"
srcCon.Userid = "JDoe"
srcCon.Password = "xyzzy"
srcCon.Metadata = "customer"
srcCon.Connect
' perform a select and get the records with
' the fields wanted, in our fldLstRecord object
If (srcCon.Select (Nothing, 1, fldLst) <> 0) Then
Print "Table contains " & fldLst.FieldCount & " fields."
' now map the fields of interest, in the order needed,
' discarding fields that we're not interested in.
Call fetchLst.Map (fldLst, "ContactName, CompanyCity, CompanyState")
Print "Fetch field list contains " & fetchLst.FieldCount & " fields."
Set cname = fetchLst.GetField (1)
Set ccity = fetchLst.GetField (2)
Set cstate = fetchLst.GetField (3)
REM fetch a record from the result set
srcCon.MapByName = True ' because the fields in the result set are not in this order.
Print "Fetching ContactName, CompanyCity, and CompanyState fields"
While (srcCon.Fetch (fetchLst, 1, 1) > 0)
count = count + 1
Print Cstr(count); Tab(3); cname.Text(0); Tab(28); _
ccity.Text(0); Tab(42); cstate.Text(0)
Wend
End If
End Sub
Example Output
Table contains 8 fields.
Fetch field list contains 3 fields.
Fetching ContactName, CompanyCity, and CompanyState fields:
1 Peter Jay Okend NH
2 Trent Kent Farmtown RI
3 Joan Thomast Lawrens MN