Using CitectSCADA > Using Devices > Formatting Data in the Device > dBASE and SQL database devices format

dBASE and SQL database devices format

The format specifies the structure (field names and field widths) of the database. The format has the following syntax:

{<field name>, <width>}

You need to use braces ({ }) to enclose each field, for example:

Format

{Tag,8}{Name,32}

In this case, the database is created with two database fields - Tag, with 8 characters, and Name, with 32 characters. The size of each database field is determined by the width you specify in the format. (Justification character are ignored.) Every database field is character (string) field types.

You can define your own fields (as well as the standard CitectSCADA fields) for the database device, for example:

Format

{Name,16}{Water,8}{Sugar,8}{Flour,8}
{Salt,8}{Yeast,8}{Milk,8}

This database device has the following structure:

Don't leave any spaces between each field definition or at the end of the format string, or CitectSCADA creates extra fields for each space (in the device). Do not specify a field name longer than 10 characters, or CitectSCADA truncates the name to 10 characters. (The dBASE file format limits field names to a maximum of 10 characters.)

In this example, the database is created with seven database fields. To access the above dBASE device, use a Cicode function similar to the following:

hDev = DevOpen("Recipe");
DevFind(hDev, "Name", "Bread");
PLC_Water = DevGetField(hDev, "Water");
PLC_Sugar = DevGetField(hDev, "Sugar");
. . .
. . .
DevClose(hDev);