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

db.open-odbc

 
 

Library: Database access (OMDB)
Import: omdb.xmd
Return type: dbDatabase

Returns: A db.database object for the opened database connection.


Declaration

define external db.database function db.open-odbc
          value string dsn

or

define external db.database function db.open-odbc
          value string dsn
    user  value string user-name
 password value string password

Argument definitions

dsn
is the named data source you want to be connected.
user-name
is the user name that will be supplied to the database when the connection is made.
password
is the password that will be supplied to the database when the connection is made.


Purpose

Use db.open-odbc to create a connection to an ODBC-compliant database. The function returns a db.database OMX component.

Requirements

dsn must:

Else external exception OMDB501 is thrown.

User-name and password are optional with default values of an empty string. Check the requirements for access to the specified database.

Usage Notes

You must have declared an OMX db.database variable (either global or local) to reuse a database connection in other OMDB functions.

This function will throw external exception OMDB501 if there are any ODBC driver errors. The exception will include any error numbers and descriptive text generated by the ODBC driver. Consult your driver documentation for further details on the error condition.

Example #1:

Create a connection to the ODBC compliant database named DatabaseDemo. No user-name or password is required to access this database. This connection can be reused in other OMDB functions.

  import "omdb.xmd" prefixed by db.
  
  process
    local db.database my-database
    	. . .
    set my-database to db.open-odbc "DatabaseDemo"

Example #2:

Create a record set from a query to an unopened ODBC compliant database named Collection1. A user-name and password are required to access this database. Note that you will be unable to reuse this connection in other OMDB functions as it has not been assigned to a variable. The connection will close automatically when it is out of scope.

  import "omdb.xmd" prefixed by db.
  global db.field my-query variable initial-size 0
  
  process
     db.query db.open-odbc "Collection1"
    	user "Phred123"
    	password "ecorde143"
       sql  ( 'SELECT EmpName, EmpName, {fn ucase(EmpName)}, Salary '
              || 'FROM Employee'  )
       into my-query

    Related Syntax
   db.close
   db.execute-in
   db.query
   db.database
   db.delete
   db.procedure
   db.commit
   db.set-transaction-type
   db.rollback
   db.statement
   db.open-oci8i
 
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.