Transactions are an integral part of a client/server database. IBExpress provides the TIBTransaction component to manage transactions. Each TIBTransaction component handles one transaction on the database to which it is assigned.
A TIBTransaction component enables you to specify the properties of a transaction. These are stored in the Params property of the component. TIBTransaction has a built-in editor that enables you to use four predefined transaction settings. In Bug Tracker, we will use the Read Committed setting. InterBase and IBExpress both default to the transaction to Snapshot. Changing to Read Committed is a normal first step when dropping a new TIBTransaction onto a data module or form.
CAUTION
Most problems involving
This problem was because of a known logic bug in IBExpress wherein a dataset will commit a transaction that it autostarts if there are no other active datasets when it
If you run across a problem such as this, the TIBSQLMonitor component is invaluable for tracing the transaction events that are occurring.
|
|
|
|
| Top |
IBExpress offers many different ways of working with the information in a database. These include TIBTable , TIBQuery , and TIBDataSet . If a TIBTable or TIBQuery is used, the TIBUpdateSQL component can also be used.
The TIBUpdateSQL component is designed for use with the TIBTable or TIBQuery component. It provides SQL statements to be executed to perform the actions needed for the four different operations you can perform on the database: deleting, inserting, updating, and refreshing.
The component has an editor (as seen in Figure 10.2) to supply the creation of these statements. The editor can only work when the component has been assigned to a
TIBTable
or
TIBQuery
, and the
TIBTable
or
TIBQuery
has been set up for a specific table or query. This is because
The editor will automatically create a base statement for each of the four operations, but it might be necessary to edit the automatically generated statements to take into account triggers, stored procedures, or other
Just like the standard C++Builder data access
TIBTable
attempts to return a live dataset, but because this is an actual client-server database rather than a desktop database, it might not be possible under certain conditions. This is
TIBTable
is rarely a good component for client/server
The use of the
Insert
function of
TIBTable
is not recommended. Appending data to a specific position in a SQL backend has no real meaning. In a
TIBQuery returns a read-only dataset based on any InterBase SQL statement. TIBQuery offers a higher degree of control over what data is presented than TIBTable . By using joins, you can specify SQL queries that combine information in several different tables. TIBQuery should be used instead of TIBTable whenever possible.
If the
TIBQuery
needs to insert, edit, or delete information, a
TIBUpdateSQL
component must be assigned to it. However, it is typically preferable to use a
TIBDataSet
, which combines the capabilities of a
TIBQuery
and
TIBUpdateSQL
, to accomplish these
TIBDataSet
combines the data-selection features of a
TIBQuery
component with the data-editing features of a
TIBUpdateSQL
component. One difference between
TIBDataset
and
TIBQuery
is that the
Params
for
TIBDataset
are not
TParams
, but
TIBExpressSQLDA
instead. The
TIBExpressSQLDA
parameter type is required if you are using InterBase version 6.0 and need Int64 parameters. For the Bug Tracker application, we will make
The
TIBSQL
component offers a fast, low-overhead means of executing InterBase data operations. Descended from the
TComponent
object, the
TIBSQL
component does not support any of the
TIBStoredProc can work with data-enabled objects, but a TIBQuery or TIBDataSet should be used for stored procedures that return multiple rows or components. Designed to simplify accessing stored procedures, TIBStoredProc enables you to specify the procedure to execute and the parameters for that procedure. Note that any values that are returned by the stored procedure will be accessible through the corresponding parameter.
Using InterBase and stored procedures or triggers, events can be set up to be generated by the server. An example of a generated event is the command
POST_EVENT
'BUG_DELETE'
, where
BUG_DELETE
is the name of the event
The TIBEvent component allows the client application to tell the server what events it wants to be notified of, receive that notification, and generate an OnEventAlert() event. Bug Tracker executes a simple ShowMessage() when a bug record is deleted, but more complex functions could easily be included.
Events of this
|
|
| Top |