data type
Library: Database access (OMDB legacy)
Include: omdb.xin |
The dbField OMX component allows you to access the data value that exists within a row of a database record set field. This OMX component is a shelf, where each field value is placed in a separate item on the shelf, and each item key is the unique name of the field. Use the dbField OMX component in conjunction with dbDatabase to create a connection to a database and obtain a read-only set of data from that database.
The OmniMark Database dynamic link library file ("omdb.dll") creates the dbField OMX component. The related include file ("omdb.xin") defines the interface to that component. To use dbField OMX components in your program, you must include the following include statement in your program:
include "omdb.xin"
Within your program, you can create as many instances of the dbField OMX component as you require by declaring global and local shelves of type "dbField". These shelves must be declared as variable.
When you use the dbQuery function, the dbField shelf is automatically bound to the record set created by the SQL query that you specify in that function. When you move the data cursor in the record set, using the dbRecordMove function, the dbField shelf is automatically repopulated with whatever values are in the current row. You retrieve values from the dbField OMX variable with the dbFieldValue function.
Please refer to OMX Components for a general description of OMX components and how they are used.
The functions
dbQuery
- execute an SQL query on the specified database.
dbProcedureExecute
- execute a stored procedure. (Must be a query.)
dbFieldValue
- commit all the insert, delete, or update operations performed since the last dbCommit or dbRollback.
dbRecordExists
- check whether the data cursor is positioned on an existing row or not.
dbRecordMove
- change the position of the data cursor within the specified record set.
dbRecordSetMove
- test for another result set.
Once you have declared your dbField OMX shelves, you can use those variables in the dbQuery
and dbFieldValue
functions that are part of the OmniMark Database legacy library. For example:
include "omdb.xin" process local dbDatabase my-database local dbField my-query variable local stream SQL-query initial { "select C.CourseName, S.StudentName, SC.Grade " || "from Student S, Course C, StudentCourse SC " || "where SC.CID = C.CID and S.SID = SC.SID " } set my-database to dbOpenODBC "MyDatabase" dbQuery my-database SQL SQL-query record my-query repeat exit unless dbRecordExists my-query repeat over my-query output dbFieldValue my-query null '-DNF-' output '%t' when ! #last again output '%n' dbRecordMove my-query again