Append Method for LCFieldlist
This method creates a new field and appends it to an existing fieldlist.
Defined In
LCFieldlist
Syntax
Set field = fieldlist. Append (fieldName, dataType)
Parameters
Parameter |
Description |
---|---|
fieldName |
String. The name for the field. |
dataType |
Long. The constant for the data type. One of the following: |
LCTYPE_INT |
|
LCTYPE_FLOAT |
|
LCTYPE_CURRENCY |
|
LCTYPE_NUMERIC |
|
LCTYPE_DATETIME |
|
LCTYPE_TEXT |
|
LCTYPE_BINARY |
|
LCTYPE_FIELDLIST |
|
LCTYPE_CONNECTION |
Return Value
Value |
Description |
---|---|
LCField |
A pointer to the new field. |
Usage Notes®
If you need the field format to be other than the default for its type, or if you need to refer to the field conveniently later, store the new field reference in a variable. The code that follows demonstrates this technique.
Example
Option Public
Option Explicit
Uselsx "*lsxlc"
Sub Initialize
REM this example copies a DB2 table.
Dim src As New LCConnection ("db2")
Dim fldLstRecord As New LCFieldList
Dim companyname As LCField
REM build the table definition.
Call FldLstRecord.Append ("ACCOUNTMANAGER", LCTYPE_INT)
Call FldLstRecord.Append ("CONTACTNAME", LCTYPE_TEXT)
Set companyname = FldLstRecord.Append ("COMPANYNAME", LCTYPE_TEXT)
Call companyname.SetFormatStream(, 40) ' max length for company name _
is 40 chars.
REM set properties to connect to both data sources.
src.Database = "Gold"
src.Userid = "JDoe"
src.Password = "xyzzy"
src.Metadata = "customer"
REM now connect.
src.Connect
REM create it based on the metadata property already set previously.
On Error LCFAIL_DUPLICATE Goto tableexists
Call src.Create (LCOBJECT_METADATA, fldLstRecord)
Print "The '" & src.Metadata & "' table did not exist so it was created."
End
tableexists:
Print "The '" & src.Metadata & "' table exists."
End
End Sub
Example Output
The 'customer' table exists.