The message interface is used to send messages to the SQL broker objects.
SQL broker objects can be of the following classes:
Class |
Short Description |
A cSQLStatement object is created for every statement handle that is allocated. |
|
A cSQLConnection object is created for every connection handle that is allocated. An object of this class creates cSQLStatement objects as child objects. |
|
The main entry point for embedded SQL messages. An object of this class creates cSQLConnection objects as child objects. |
The DataFlex class definition is synchronized with the SQL definitions. API’s for SQL environments use the same hierarchical structure for connections and statements. The DataFlex classes add an extra layer of abstraction to this setup. They allow one program to create a connection through the DataFlex DB2 Driver and the DataFlex SQL Server Driver at the same time.
The only object that the programmer needs to define is the outer, cSQLHandleManager object. Once that object is created, messages can be send to it that will automatically create cSQLConnection objects. A code sample that executes an update statement follows:
Handle hoSQLMngr
Handle hdbc hstmt
Object oSQLManager Is A cSQLHandleManager
Move Self To hoSQLMngr
End_object
Open Customer
Get SQLFileConnect Of hoSQLMngr Customer.File_number To hdbc
Get SQLOpen Of hdbc To hstmt
Send SQLExecDirect To hstmt “UPDATE Customer SET AccountMngr = ‘John’ WHERE AccountMngr = ‘Mary’”
Send SQLClose To hstmt
Send SQLDisconnect To hdbc
As is evident from the sample, the connection handle and statement handle used in DataFlex are actually object handles. Internally, the underlying logic will use the handles, as is custom in the driver environment. Possible differences between drivers are hidden from the DataFlex programmer. This allows one consistent programming interface that is independent from the underlying driver. A program using Embedded SQL can switch to another driver without having to adjust the code.
We will discuss the classes in the order they are normally used, cSQLHandleManager, cSQLConnection and cSQLStatement.
You will notice that we do not discuss class inheritance in the discussion of the three classes. The inheritance is not important. The classes are based on the cObject class not because they use array features, but because it is the smallest, most basic non-visual class.
Direct usage of private message is not recommended. Data Access reserves the right to completely redefine the private interface of a class. If a programmer uses the messages marked as private, there is no guarantee these will work, or work the same way, in a later revision.