From Onda Technology Institute Wiki
Jump to: navigation, search

Back to OCL


The F2 module of OCL is a database access module. This module supplies the namespace Onda::SQL. It also supplies a command-line program to connect to databases and execute queries, osql.


The first thing you need to do is to include the relevant headers and libraries. At the time of this writing, the current header is Onda/SQL.h, but that may change soon.

To access a database, you first need to get a hold of your own CDatabase object. Be aware that CDatabase may soon change to ADatabase instead, as it is an abstract class.

You need to ask the CDatabase class for your connection object, using one of the Connect methods available. The object returned is a derivative of the CDatabase class for the database type you selected. That will be your connection handle. On that handle you can perform your queries and execute your statements.

You have two choices:

  1. Execute a query or statement directly;
  2. Prepare a statement for multiple executions.

If you choose the first method, whenever you perform a query, you will be handed a CResult object from which you can retrieve your data.

In the case of using the second method, prepared statements, you'll be handed a handle to your statement and then you can execute it as many times as you like. For each time you execute your statement, you receive a new CResult object.

From CResult objects you can retrieve your data in the form of a CRow, representing each new row retrieved. Data in CRow objects can be accessed by column index or name, since the class also provides an associative array interface.

TODO: continue

Driver creation

If what you want is to create a new driver for F2, you will need to derive almost all the classes. If you follow the instructions and study the header files, you will be able to do it quickly. You might like to refer tho the source code of the Onda::F7 and Onda::F8 modules for a reference implementation. Those are the already available MySQL and Firebird/Interbase modules respectively.


This module provides the following classes:


Links of interest

Perl Compatible Regular Expressions