Element: database.exec { }

Type

callback

Description

A set of commands to be executed when a background command, previously issued to the database interface, has completed, or when an event occurs on the external database. Background commands are not available when the database is a network service.

When this procedure is executed, the database identifier is passed to it as parameter 1.

When this procedure is executed on completion of a background command, the background name is passed as parameter 2 (a string).

When this procedure is executed on receipt of an external database event, the event name is passed to it as parameter 2 (a string), and the event text is passed to it as parameter 3 (a string).

Parameters

database.exec (<database>,<string>{,<string>})

Examples

Define an exec procedure to be executed on completion of an SQL select command.

mydb.exec = {
    args d=database, name=string
    numeric age
    db d { *fetch age }
    tell <'Age of candidate',age>
}
db my_db {
  *(gotit) select age from mytab \
      where mame matches 'Smith'
}

Define an exec procedure to be executed on receipt of an external event.

database mydb,-name='mydatabase',-prop=ingres
mydb.exec = {
    args d=database, name=string, text=string
    tell <'Event:', name>
    tell <'Text:', text>
}

The callback may be called explicitly if required. This may be done in one of two ways:

# Assume mydb is the database identifier.
database.exec(mydb,’State1’)

or

mydb.exec('State1')