Creates a temporary table that exists until closed.

CREATE CURSOR alias_name 
...[CODEPAGE=nCodePage]
   (fname1 cFieldType [(nFieldWidth [, nPrecision])] [NULL | NOT NULL] 
   [CHECK lExpression [ERROR cMessageText]] 
   [AUTOINC [NEXTVALUE NextValue [STEP StepValue]]]
   [DEFAULT eExpression] [UNIQUE [COLLATE cCollateSequence]]
   [NOCPTRANS] [, fname2 ...]) 
   | FROM ARRAY ArrayName

Parameters

alias_name

Specifies the name of the temporary table to create. The alias_name parameter can be a name expression.

nCodePage

Specifies the code page to use. For a list of code pages, see Code Pages Supported by Visual FoxPro.

fname

Specifies the name of a field in the temporary table. Each fname can be a name expression.

cFieldType

Specifies a single letter or a long name indicating the field's data type.

nFieldWidth

Specifies the width of the field specified with fname. Some data types require that you specify a value for nFieldWidth.

nPrecision

Specifies the number of decimal places for the specified data type. Some data types require that you specify a value for nPrecision.

The following table shows the possible values for cFieldType, nFieldWidth, and nPrecision.

cFieldType nFieldWidth nPrecision Description

W, Blob

-

-

Blob

C, Char, Character

n

Character field of width n

Y, Currency

Currency

D, Date

Date

T, DateTime

DateTime

B, Double

d

Double

G, General

General

I, Int, Integer

Integer

L, Logical

Logical

M, Memo

Memo

N, Num, Numeric

n

d

Numeric field of width n with d decimal places

F, Float

n

d

Floating Numeric field of width n with d decimal places

Q, Varbinary

n

-

Varbinary field of width n

V, Varchar

n

-

Varchar field of width n

The nFieldWidth and nPrecision parameters are ignored for W, Y, D, T, G, I, L, and M types. If nPrecision is not included for the N, F, or B types, the nPrecision parameter defaults to zero (no decimal places).

NULL | NOT NULL

Specifies whether null values are allowed in the field. NULL permits null values, while NOTNULL does not allow null values.

CHECK lExpression

Specifies a validation rule for the field. The lExpression parameter must evaluate to a logical expression and can be a user-defined function or a stored procedure.

ERROR cMessageText

Specifies an error message. Visual FoxPro displays this message when the validation rule specified in the CHECK clause generates an error. The message displays only when data is changed within a Browse window or Edit window.

AUTOINC [NEXTVALUE NextValue [STEP StepValue]]

Enables autoincrementing for the field.

NextValue specifies the start value and can be a positive or a negative integer value ranging from 2,147,483,647 to -2,147,483,647. The default value is 1. You can set NextValue using the Next Value box on the Fields tab in the Table Designer.

StepValue specifies the increment value for the field and can be a positive, nonzero integer value ranging from 1 to 255. The default value is 1. You can set StepValue using the Step box on the Fields tab in the Table Designer.

Autoincrementing values cannot be null (.NULL.).

NoteNote

Tables containing automatically incrementing field values append table-buffered records approximately 35% slower than tables without automatically incrementing field values, which might affect performance. When using table buffering, the table header is locked when the record is appended.

DEFAULT eExpression

Specifies a default value for the field. The data type of eExpression must be the same as the specified field's data type.

If you use the AUTOINC clause to turn on autoincrementing for a field and specify a default value, Visual FoxPro stores the default value in the table but does not use it. Visual FoxPro uses the default value if you use the ALTER TABLE - SQL command to remove autoincrementing for the field.

UNIQUE

Creates a candidate index for the field. The candidate index tag has the same name as the field. For more information about candidate indexes, see Visual FoxPro Index Types.

COLLATE cCollateSequence

Specifies a collation sequence other than the default setting, MACHINE. The cCollateSequence parameter must be a valid Visual FoxPro collation sequence. For more information about setting collation sequences, see Optimizing International Applications and SET COLLATE Command.

NOCPTRANS

Prevents translation to a different code page for Character, Memo, and Varchar fields. You can specify NOCPTRANS only for Character, Memo, and Varchar fields.

FROM ARRAY ArrayName

Specifies the name of an existing array whose contents are the name, type, precision, and scale for each field in the temporary table. You can use the FROM ARRAY clause instead of specifying individual fields. For the proper format of the contents of the array, see AFIELDS( ) Function.

Autoincrementing is turned on when the step value is greater than 0.

Expand imageRemarks

Expand imageExample

Expand imageSee Also