Friday, May 28, 2010

FAQs – May 2010

Adding Tables to a Dictionary Using a Server-Side Alias

When you are connected to Advantage using a server-side alias you cannot add tables to a dictionary by simply browsing to the tables. Tables are generally added to a database using the AdsDDAddTable90 API call. This uses Windows API calls to locate the file and add it to the dictionary. When using a server-side alias the path supplied to the AdsDDAddTable90 call is not a valid Windows file path.

You can add tables using a server-side alias path using the sp_AddTableToDatabase system procedure. This system procedure can use a physical path or UNC path to the free table to be added. This path will be properly resolved by the server prior to adding the table to the database.

// Add a free table to a data dictionary
EXECUTE PROCEDURE sp_AddTableToDatabase(
  'Customers', // Object name for dictionary 
  '\\server\alias\customer.dbf', // UNC Path
  1, // DBF/NTX table type
  2, // OEM Collation
  'Cust_Id.ntx;LastName.ntx', // Index files
  NULL ); // No comments
EXECUTE PROCEDURE sp_AddTableToDatabase(
  'Employees', // Object name for dictionary 
  '\\server\alias\employee.adt', // UNC Path
  3, // ADT table type
  1, // ANSI Collation
  NULL, // No need to include additional index files
  NULL ); // No comments

Rejected Connections

Advantage 9 and newer automatically increase the connections limit if it is exceeded which should avoid the client seeing any errors if the initially configured value is exceeded. However, when using TCP/IP communications instead of the default UDP/IP, the number of connections is limited to 3000. If this limit is reached then clients may receive a 7033 "Maximum Number of Connections Exceeded" even if the connections parameter is set much higher than 3000.

To avoid this error use the default UDP/IP communication type or use a mix of communication types to avoid exceeding the 3000 connection limit. The TCP/IP communication option was added in version 8.1 of Advantage. Version 8.1 has a limit of 1000 TCP/IP connections.

Where Do I Find Advantage Constants

Many of the Advantage API calls and system procedures use constants for various settings. These constants are also found in some of the system tables, for example system.indexes reports the index type as an integer value ( see this tip ). These constants are all defined in the Advantage Client Engine header file which is distributed with most clients.

In Delphi many of the constants are already defined, for example the AdsTableOptions class contains various options which map to the corresponding constants. Beginning with version 9 of the Advantage .NET Data Provider the Advantage Client Engine namespace was added. You can use the object explorer in Visual Studio to view the defined constants.

Here are the constants used in the system.tables table.

Table Types

Table Permission Level
Allow Hidden Field Filters 1
Prevent Hidden Field Filters 2
SQL Access Only 3

Table Caching
No Caching 0
Cache Reads 1
Cache Reads/Writes 2

No comments: