swirl Guide to OmniMark 5   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesOMX VariablesErrors
 
 
  dbField    

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.

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.

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. For example:

     ; required include statement
     include "omdb.xin"

     ; global dbField variable declarations
     global dbField my-fields-1 variable
     global dbField my-fields-2 variable

     process
        ; local dbField variable declarations
        local dbField my-fields-3 variable
        local dbField my-fields-4 variable

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 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 " ||
           "order by C.CID, SC.Grade desc"
        }

        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

The dbField OMX component is not copyable. This means that when you set the value of one dbField shelf to the value of another dbField shelf, you end up with two variables pointing at the same set of field values. You are able to read from both shelves, but you are actually reading these from the same set of field values, whether you use the original dbField shelf or its copy.

   
----  

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ OMX ] [ OMX ] [ ERRORS ]

Generated: August 11, 2000 at 3:07:05 pm
If you have any comments about this section of the documentation, send email to docerrors@omnimark.com

Copyright © OmniMark Technologies Corporation, 1988-2000.