swirl
Guide to OmniMark 8   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Syntax   Related Concepts   Other Library Functions  
function  

db.insert

 
 

Library: Database access (OMDB)
Import: omdb.xmd

Declaration

define external function db.insert
  into  value     db.table  table
  from  read-only stream    values
  null  value     string    null   optional

Argument definitions

table
is an open db.table 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 db.insert to insert a record into a table using the data values in a stream shelf.

Requirements

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 db.table OMX component.

  import "omdb.xmd" prefixed by db.
  
  process
      local db.database this-db
      local db.table 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 db.open-odbc 'dbDemo'
      set course to db.open-table in this-db named 'Course'
  
      ; add record to the table (Method #1)
      db.execute-in this-db sql SQL-insert
  
      ; add record to the table (Method #2)
      db.insert into course from course-data

    Related Syntax
   db.open-odbc
   db.database
   db.open-table
   dbTableClose
   db.update
   db.delete
   db.table
   db.commit
   db.rollback
 
Related Concepts
   Using the OMDB library
 
Other Library Functions
   db.advance-recordset
   db.close
   db.commit
   db.compile-statement
   db.database
   db.delete
   db.discard
   db.document-writer-sedna
   db.execute
   db.execute-in
   db.field
   db.insert
   db.is-null
   db.move-dynamic-record
   db.move-record
   db.omdb-version
   db.omdb-version-oci10g
   db.omdb-version-oci11g
   db.omdb-version-oci8i
   db.omdb-version-oci9i
   db.omdb-version-odbc
   db.omdb-version-sedna
   db.open-oci10g
   db.open-oci11g
   db.open-oci8i
   db.open-oci9i
   db.open-odbc
   db.open-procedure
   db.open-sedna
   db.open-table
   db.prepare
   db.procedure
   db.query
   db.reader
   db.record-exists
   db.rollback
   db.set-transaction-type
   db.statement
   db.streaming-execute
   db.table
   db.update
   db.writer
 
 

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

OmniMark 8.2.0 Documentation Generated: March 13, 2008 at 3:27:39 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2008.