| A KeyDef is a way to define the key columns in a table. The KeyDef is generally used in conjunction with a TableDataSet. Essentially a KeyDef is what forms the WHERE clause for an UPDATE or DELETE.
In order to use the KeyDef, you simply use it like this:
KeyDef kd = new KeyDef().addAttrib("key_column_a");
TableDataSet tds = new TableDataSet ( connection, "table", kd );
tds.fetchRecords();
Record rec = tds.getRecord(0);
rec.setValue("column_name", "new value" );
rec.save();
tds.close();
In the above example, Record 0 is retrieved from the database table and the following update statement is generated:
UPDATE table SET column_name=? WHERE key_column_a=?
author: Jon S. Stevens version: $Revision: 568 $ |