dbField

data type

Library: Database access (OMDB legacy)
Include: omdb.xin


Purpose

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.

Usage Notes

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.

Related OMDB library functions:

The functions

are used to establish dbField components. The dbField objects are used by the following OMDB library functions:

Example

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