TIBCO ActiveSpaces®
|
The following sections briefly describe how to use the C API. Refer to the Concepts guide for more details on the concepts employed.
The first thing any program will need to do is create a tibEx
object to catch errors:
Next the program needs to initialize ActiveSpaces and create tibdgConnection, tibdgSession and tibdgTable objects:
In the code above, the type of tibdgSession that is created is a non-transactional one, so any operations on the tibdgTable will be applied immediately rather than requiring the program to call tibdgSession_Commit.
To add data to the table the program creates a tibdgRow containing the appropriate data and then calls tibdgTable_Put to put the data into the table. In the code fragment below, two rows are put into the table:
Once the row has been put into the table, the tibdgRow can either be re-used or destroyed. A tibdgRow object should only be used with the tibdgTable object that created it.
To retrieve a row from a table the program creates a tibdgRow object and sets the primary key fields to match those of the row to be fetched. This "key row" is then passed to tibdgTable_Get, which returns a new tibdgRow containing the data retrieved from the table.
If there is no row with the given key, then tibdgTable_Get return will NULL
. The program must destory both tibdgRow objects.
To retrieve multiple rows from the table the program uses a tibdgIterator created with a filter expression that is used to match the rows to be returned:
To iterate over all the rows in the table specify NULL
for the filter.
When the program has completed all its operations on a given table, it should close the table. When all processing is complete, the program should destroy the session, close the connection and then close the library:
Finally the program will destroy the tibEx
object.