AppendFrom

<< Click to Display Table of Contents >>

Navigation:  Apollo VCL Components > Apollo VCL Component Reference > TApolloTable > TApolloTable Methods >

AppendFrom

Declaration

function AppendFrom( sFileName: String;

iSourceType: Integer;  

sForExpr: String ): WordBool;

Description

Appends data from a source table to the current table. All fields with matching names and types are appended to the current table. If field length differs, data in the destination table is either truncated or padded with spaces.

 

Deleted records in the source file are not appended to the target table.

 

Speed Tip: If a structural index exists for the source table, rename it before calling AppendFrom. The operation takes less time to complete if the source and target tables are in natural order with no open indexes. For any open non-structural index files, use CloseIndexes on the target (current) table and reopen and reindex after appending.

image\tip.gif WARNING: If a structural index exists for the source table, and the index expression(s) contain alias name references, xBase evaluation errors will occur because Apollo assigns an internal alias name to the source table when it is opened in AppendFrom.

Parameters

sFileName: The name of the source table including full path and extension information if desired. The type of the source table must be the same as the type of the current table (i.e., if the current table is SDENTX, the source table must also be SDENTX).

image\tip.gif When working with a remote table via Apollo Database Server, you may only append from a source table that is located in the same Database directory as the table. The remote client cannot specify a physical server drive/path location and must use the defined server alias instead.  Any physical drive/path included in the sFileName parameter will be ignored for remote tables.

iSourceType: Use one of the following type defined constants.

 SDENTX 1 CA-Clipper compatible DBF-NTX driver

 SDEFOX 2 FoxPro DBF-IDX/CDX driver

 SDENSX 3 HiPer-SIx DBF-NSX driver

 COMMA_DELIM 21 Comma-Delimited Text File

 SDF_FILE 22 Space-Delimited (SDF) Text File

 TAB_DELIM 23  Tab-Delimited Text File

 SPACE_DELIM 24  Space-delimited Text File

 OEMNTX 31 Source SDENTX file translated from OEM

 OEMFOX 32 Source SDEFOX file translated from OEM

 OEMNSX 33 Source SDENSX file translated from OEM

 

Sample Data

COMMA_DELIM

"Homer","Simpson","41 Maiden Lane","Springfield"

SDF_FILE

Homer Simpson 41 Maiden Lane

TAB_DELIM

"Homer" "Simpson" "41 Maiden Lane"

SPACE_DELIM

"Homer " "Simpson " "41 Maiden Lane "

 

image\tip.gif WARNING: When appending from an ASCII text file into a .DBF file, you must insure that the last line of the ASCII file also includes a carriage return and line feed (CRLF) combination. Without that, the operation cannot terminate properly.

 

sForExpr: An xBase expression defining a filtered subset to be applied to the source table (e.g., 'upper(trim(city)) = "LOS ANGELES"' ). If all of the records in the source file are to be appended, pass the parameter as a NULL string ('' or #0).

Return Value

If the append is successful, True is returned. If the function fails, False is returned. If the source file is empty, True is returned.

Delphi Example

with ApTbl do

begin

 Open;

 if AppendFrom( 'c:\Apollo\cust.dbf', SDEFOX, '' ) then

         ShowMessage( 'Appended file successfully' )

 else

         ShowMessage( 'AppendFrom failed' );

 GoTop;

end;

C++Builder Example

ApTbl->Open();

if (ApTbl->AppendFrom( "c:\\Apollo\\cust.dbf", SDEFOX, "" ))

 ShowMessage( "Appended file successfully" );

else

 ShowMessage( "AppendFrom failed" );

ApTbl->GoTop();

See Also

CopyFile, CopyStructure, SetGaugeHook