Note | This command is defined in a header file and will be preprocessed by the X# preprocessor to a function call. If you disable the standard header (-nostddefs) files then this command will not be available. If you tell the compiler to use a different standard header file (-stddef ) then this command may also be not available |
Purpose
Import records from a database or text file.
Syntax
APPEND FROM <xcSourceFile> [FIELDS <idFieldList>]
[<Scope>] [WHILE <lCondition>] [FOR <lCondition>]
[SDF] | [DELIMITED [WITH <xcDelimiter> | BLANK]] |
[VIA <cDriver>] [INHERIT FROM <acRDDs>]
Arguments
FROM <xcSourceFile> | The name of the source file from which to add records, including an optional drive, directory, and extension. See SetDefault() and SetPath() for file searching and creation rules. The default extension for database files is determined by the RDD. For text files, it is .TXT. |
| This command attempts to open <xcSourceFile> in shared mode. If the file does not exist, a runtime error is raised. If the file is successfully opened, the operation proceeds. If access is denied because, for example, another process has exclusive use of the file, NetErr() is set to TRUE. |
FIELDS <idFieldList> | The list of fields to append from <xcSourceFile>. The default is all fields. |
| Only fields with the same names and types in both files are appended. If fields with the same name do not match in data type, a runtime error is raised. |
<Scope> | The portion of the current database file to process. The default is all visible records. Scope is one or more clauses of:
[NEXT <NEXT>] Optionally specifies the number of records to process starting
with the first record of the source file.
[RECORD <rec>] An optional record ID If specified, the processing begins
with this data record in the source file.
[<rest:REST>] The option REST specifies whether records are sequentially
searched only from the current up to the last record.
If a condition is specified, the option ALL is the default value.
[ALL] The option ALL specifies that all records from the source file are imported.
This is the default setting. |
WHILE <lCondition> | A condition that each visible record within the scope must meet, starting with the current record. As soon as the while condition fails, the process terminates. If no <Scope> is specified, having a while condition changes the default scope to the rest of the visible records in the file. |
FOR <lCondition> | A condition that each visible record within the scope must meet in order to be processed. If a record does not meet the specified condition, it is ignored and the next visible record is processed. If no <Scope> or WHILE clause is specified, having a for condition changes the default scope to all visible records. |
SDF | A System Data Format file with format specifications as shown in the table below. Records and fields are fixed length. |
Character fields | Padded with trailing blanks |
Numeric fields | Padded with leading blanks or zeros |
Record separator | Carriage return/linefeed |
End of file marker | 1A hex or Chr(26) |
DELIMITED [WITH <xcDelimiter>] |
| A text file in which character fields are enclosed in double quote marks (the default delimiter) or the specified <xcDelimiter>. Fields and records are variable length, and the format specifications are shown in the table below: |
Character fields | Can be delimited, with trailing blanks truncated |
Numeric fields | Leading zeros can be truncated |
Record separator | Carriage return/linefeed |
End of file marker | 1A hex or Chr(26) |
Note: Delimiters are not required and APPEND FROM correctly handles character fields not enclosed with them.
| A text file in which fields are separated by one space and character fields are not enclosed in delimiters. The format specifications are shown in the table below: |
Character fields | Not delimited, trailing blanks can be truncated |
Numeric fields | Leading zeros can be truncated |
Field separator | Single blank space |
Record separator | Carriage return/linefeed |
End of file marker | 1A hex or Chr(26) |
Warning! If the DELIMITED WITH clause is specified on an APPEND FROM command line, it must be the last clause specified.
VIA <cDriver> | The name of the RDD that will service the work area. If not specified, the default RDD as determined by RDDSetDefault() is used. |
| A one-dimensional array with the names of RDDs from which the main RDD inherits special functionality. This allows you to use RDDs with special capabilities, like encryption or decryption, in different work areas with different database drivers. These RDDs overlay special functions of the main RDD (specified with the VIA clause). If multiple RDDs (specified with this INHERIT FROM clause) implement the same function, the function associated with the last RDD in the list takes precedence. |
Notes
Deleted records: If SetDeleted() is FALSE, deleted records in <xcSourceFile> are appended to the current database file and retain their deleted status. If SetDeleted() is TRUE, however, deleted records are not visible and are, therefore, not processed.
Unmatched field widths: If a field in the current database file is character type and has a field length greater than the incoming <xcSourceFile> data, APPEND FROM pads the source data with blanks. If the current field is character data type and its field length is less than the incoming source data, the source data is truncated to fit. If the current field is numeric type and the incoming source data has more digits than the current field length, a runtime error is raised.
Examples
This example demonstrates an APPEND FROM command using a fields list and a condition:
USE sales NEW
APPEND FROM branchfile FIELDS Branch, Salesman, Amount FOR Branch = 100
The next example demonstrates how a <Scope> can be specified to import a particular record from another database file:
APPEND RECORD 5 FROM temp
Assembly
XSharp.RT.DLL
See Also
COPY TO, DbApp(), DbAppDelim(), DbAppSDF(), RDDSetDefault(), SetDefault(), SetPath(), SetDeleted()