dbTableInsert

function

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

Declaration
define external function dbTableInsert
        value     dbTable  table
  from  read-only stream   values
  null  value     stream   null      optional

Argument definitions

table
is an open dbTable object.
values
is a stream shelf containing the values to insert.
null
is an optional string to represent a NULL value rather than the default unattached stream.


Purpose

Use dbTableInsert to insert a record into a table using the data values in a stream shelf.

Requirements

You must include the following line at the beginning of your OmniMark program:

  include "omdb.xin"

The database connection containing the table must be:

The table must :

The record being inserted (values) must:

Usage Notes

NULL data values may be represented as unattached streams or as an optionally defined string. The column name is identified as the key of each shelf item in the values argument.

If the record has a date, time, or timestamp field, you must represent the field's value in the OmniMark Date and Time library format. (This format returns the time with a time zone offset from UTC time, which most databases do not provide.)

Example

The following program adds two new courses to a curriculum. The table records can be added using two different methods. The first is to execute an SQL statement on the database. The second approach is to use the dbTable OMX component.

  process
  
      ; local variables
      local dbDatabase this-db
      local dbTable course
      local stream SQL-insert initial
      {  "insert into Course values " ||
          " ( '503', 'Learning Through Pain'  )"
      }
  
      local stream course-data variable initial
      {   '504' with key 'CID',
            'What is that Sound?' with key 'CourseName'
      }
      ;  create the database OMX objects
      set this-db to dbOpenODBC 'dbDemo'
      set course to dbTableOpen this-db table 'Course'
  
      ; add record to the table (Method #1)
      dbExecute this-db SQL SQL-insert
  
      ; add record to the table (Method #2)
      dbTableInsert course from course-data