A "keyless" table is one that does not have a column (or group of columns) that is specified within the table as uniquely identifying each row. Normally, Data Access Builder maps a table's primary keys to attributes called data identifiers (data IDs). If the table does not have any primary keys, you can modify one or more attributes to form the data identifier. Note: You should not map non-unique columns to be data identifiers. If you do, the retrieve method will retrieve only the first record with a specified data identifier, and the update and delete methods will affect all rows with the specified data identifier (an exception may be thrown if this happens).
For example, your table contains a list of employees with columns for job, department, phone number, and employee number, where the employee number column is a primary key. By default, Data Access Builder maps "employee number" as the data identifier and it generates code that lets you retrieve, delete, or update specific rows when you specify "employee number".
If the table contained only "department", "job", and "last name", it is conceivable that you would have more than one employee with a particular last name in a department. In this example, there is no key for the table, and so the Data Access Builder would not generate methods such as delete, update, or retrieve. However, it does generate the add method to add a row to the database and the updateFetched and deleteFetched methods to allow you to update or delete using a cursor, the last fetched row. For example:
// Open the cursor theDeptMgr.open( "WHERE job = 'ADMINISTRATOR' FOR UPDATE" );
// Fetch the first row that has ADMINISTRATOR as the job theDeptMgr.fetchNext();
// Change the Job description for cached object
theDeptMgr.element()->setJob("CLERK");
// Update the last fetched row with the cached object, close the cursor theDeptMgr.updateFetched(); theDeptMgr.close();
For keyless tables, the add method will be generated, since you need not identify one particular row in a table in order to add a row to it. However, if your schema is a table join, no add method is generated. You can use user-defined methods to add your own methods.
Unique Indices
Some tables have unique indices defined. Unique indices
are sets of columns, other than the primary key, that uniquely
identify rows in the table, and are specified as such within the
table definition. When creating a mapping for a table, you can
use a unique index as an alternate mapping for the data ID (that
is, you can change the default data ID mapping from the primary
key to a unique index). By mapping the data ID to one of these
pre-defined set of columns, you ensure that the data IDs do
uniquely identify rows in the table. This prevents your data
access application from unintentionally changing or deleting more
than one row at a time.
![]()
User-Defined Methods
Table Joins and Query Support
![]()
Change Attribute Properties
Retrieve Rows from the Database
![]()
Data Access Class Library and
Generated Class Reference
Data Access Builder Mini
Samples
