xHarbour Reference Documentation > Command Reference xHarbour Developers Network  

CREATE FROM

Creates a new database file from a structure extended file.

Syntax

     CREATE <cDatabase> FROM <cDatabaseExt> [NEW] ;
     [ALIAS <cAlias>] ;
       [VIA <rddName>]
  [CODEPAGE <cCodePage>] ;
[CONNECTION <nConnection>]]

Arguments

CREATE <cDatabase>
This is name of the database file to create. It can include path and file extension. When no path is given, the file is created in the current directory. The default file extension is DBF. <cDatabase> can be specified as a literal file name or as a character expression enclosed in parentheses.
FROM <cDatabaseExt>
This is name of the structure extended database file that holds field information for the database to create. <cDatabaseExt> can be specified as a literal file name or as a character expression enclosed in parentheses.
NEW
The newly created file is automatically opened in a new work area when the NEW option is specified. Omitting this option causes the file be opened in the current work area.
ALIAS <cAlias>
Optionally, the alias name for the work area of <cDatabase> can be specified. It defaults to the file name of <cDatabase>. If specified, the alias name must begin with an underscore or an alphabetic character, followed by a series of underscores, digits or alphabetic characters,
VIA <rddName>
The VIA option specifies the replaceable database driver (RDD) to use for opening the new database file. <rddName> is a character expression. If it is written as a literal name, it must be enclosed in quotes. If omitted, <rddName> defaults to the return value of RddSetDefault().
CODEPAGE <cCodePage>
This is a character string specifying the code page to use for character strings stored in the new database. It defaults to the return value of HB_SetCodePage().
CONNECTION <nConnection>
This option specifies a numeric server connection handle. It is returned by a server connection function which establishes a connection to a database server, such as SR_AddConnection() of the xHarbour Builder SQLRDD. When CONNECTION is used, the CREATE FROM command creates a database on the server.

Description

The CREATE FROM command uses field information stored in the records of a structure extended file to create a new database file. A structure extended datbase file has the following pre-defined field names and structure:

Fields in a structure extended file
PositionField nameTypeLengthDecimals
1FIELD_NAMECharacter100
2FIELD_TYPECharacter10
3FIELD_LENNumeric30
4FIELD_DECNumeric40

CREATE FROM reads field information from the structure extended file and creates from it a new database file. A structure extended file may have more fields than listed in the table, but only the listed ones are required.

The new database file is automatically opened.

Note:  The length of a field of type Character is calculated as the sum of FIELD_LEN plus 256 * FIELD_DEC. The maximum length, however, is limited to 64k. Use a MEMO field to store longer Character strings.

Info

See also:COPY STRUCTURE, COPY STRUCTURE EXTENDED, CREATE, DbCopyStruct(), DbCreate(), DbStruct()
Category: Database commands
Source:rtl\dbstrux.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

// please refer to the COPY STRUCTURE EXTENDED example for a usage
// scenario of CREATE FROM.

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe