swirl
Guide to OmniMark 9   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Topics   Other Library Functions  
function  

db.execute

 
 

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

Declaration

define  external function db.execute
         value       db.procedure procedure
  in     read-only   stream       inshelf   optional
  null   value       string       null      optional
  out    modifiable  db.field     outshelf  optional
  result modifiable  db.field     result    optional

or

define external function db.execute
         value       db.statement statement
   with  read-only   stream      values    optional
   null  value       string      null      optional
   into  modifiable  db.field     record    optional

Argument definitions

procedure
is the db.procedure object associated with an open procedure.
inshelf
is a shelf of stream items that contain the input and inout parameter values.
null
is a string, rather than an unattached stream, to represent a NULL value in the input parameter values.
outshelf
is a shelf of db.field items to receive output and inout parameter values, and the function procedure return.
result
is a db.field shelf attached to the attached to the result set for any SQL query executed.
statement
is a compiled db.statement object.
values
is a shelf containing the parameter data.
null
is an optional string representing null values.
record
is a shelf of db.field items bound to result set fields.


Purpose

Executing a Stored Procedure

The database where the procedure is stored must be:

procedure must:

The input shelf inshelf must The items in inShelf must be in the same order as the procedure's parameters.

At the beginning of the function, the output shelf is cleared and filled with db.field items attached to the output and inout (combined input and output) procedure parameters. The input shelf items are sequentially matched to the procedure input and inout parameters by position. You can represent NULL values in the input shelf item by an optional null specifier string or as an unattached stream.

The result shelf can contain multiple records. The input and output shelves can only contain a single record.

The result shelf is cleared in the function. If the procedure returns a result set the result shelf is filled with db.field items attached to the result set.

The output and result db.field field items are keyed with the corresponding procedure parameter names, if they exist.

If a record used by the procedure 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.)

Executing a Compiled SQL Statement

Use db.execute to execute a compiled SQL statement that was produced by the db.compile-statement function.

The db.database object supplied when the statement was compiled must be open (else external exception OMDB101).

The db.statement object statement must be open (else external exception OMDB701).

If the db.statement object is a compiled query, it requires the db.field shelf argument record to receive the results (else external exception OMDB704).

The input shelf values must:

If you specify any date, time, or timestamp values in the "values" parameter data, you must express them in the OmniMark Date and Time library format.

When you call db.execute, you must supply data for all the defined parameters. You can express null data values as unattached shelf items or as the supplied null identifier string.

db.execute allows you to execute a compiled statement and to specify all the parameter values at once. This is more efficient for small parameters.

For large parameters (for example, db.blob-type types) when there is a large amount of data to be inserted, it is more efficient to use the db.streaming-execute function, as that avoids creating an entire copy of the data in memory prior to execution.

See db.compile-statement for additional notes and examples.

    Related Topics
 
Other Library Functions
 
 

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

OmniMark 9.1.0 Documentation Generated: September 2, 2010 at 1:38:10 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2010.