Database

Inclusion code:

Service Deployment
Port Name Location Protocol Interfaces
Database documentation:
Database - - DatabaseInterface

List of Available Interfaces

DatabaseInterface

Interface documentation:

Operation Name Input Type Output Type Faults
checkConnection void void ConnectionError( undefined )
query QueryRequest QueryResult SQLException( undefined ) ConnectionError( undefined )
executeTransaction DatabaseTransactionRequest DatabaseTransactionResult SQLException( undefined ) ConnectionError( undefined )
update UpdateRequest int SQLException( undefined ) ConnectionError( undefined )
close void void
connect ConnectionInfo void InvalidDriver( undefined ) ConnectionError( undefined ) DriverClassNotFound( undefined )

Operation Description

checkConnection

Operation documentation: Checks the connection with the database. Throws ConnectionError if the connection is not functioning properly.

Invocation template:

checkConnection@Database( request )( response )

Request type

Type: void

void : void

Response type

Type: void

void : void

Possible faults thrown

Fault ConnectionError with type undefined

Fault-handling install template:

install ( ConnectionError => /* error-handling code */ )

query

Operation documentation: Queries the database and returns a result set

  Example with SQL parameters:
  queryRequest =
      "SELECT city, country, data FROM weather " +
      "WHERE city=:city AND country=:country";
  queryRequest.city = City;
  queryRequest.country = Country;
  query@Database( queryRequest )( queryResponse );

  _template:
  Field _template allows for the definition of a specific output template.
  Assume, e.g., to have a table with the following columns:
  | col1 | col2 | col3 | col4 |
  If _template is not used the output will be rows with the following format:
  row
   |-col1
   |-col2
   |-col3
   |-col4
  Now let us suppose we would like to have the following structure for each row:
  row
    |-mycol1            contains content of col1
        |-mycol2        contains content of col2
       |-mycol3        contains content of col3
    |-mycol4            contains content of col4

  In order to achieve this, we can use field _template as it follows:
    with( query_request._template ) {
      .mycol1 = "col1";
      .mycol1.mycol2 = "col2";
      .mycol1.mycol2.mycol3 = "col3";
      .mycol4 = "col4"
    }
  _template does not currently support vectors.

Invocation template:

query@Database( request )( response )

Request type

Type: QueryRequest

type QueryRequest: undefined

QueryRequest : string

Response type

Type: QueryResult

type QueryResult: void {
    .row*: undefined
}

QueryResult : void

  • row : void

Possible faults thrown

Fault SQLException with type undefined

Fault-handling install template:

install ( SQLException => /* error-handling code */ )

Fault ConnectionError with type undefined

Fault-handling install template:

install ( ConnectionError => /* error-handling code */ )

executeTransaction

Operation documentation: Executes more than one database command in a single transaction

Invocation template:

executeTransaction@Database( request )( response )

Request type

Type: DatabaseTransactionRequest

type DatabaseTransactionRequest: void {
    .statement[1,2147483647]: undefined
}

DatabaseTransactionRequest : void

  • statement : string

Response type

Type: DatabaseTransactionResult

type DatabaseTransactionResult: void {
    .result*: TransactionQueryResult
}

DatabaseTransactionResult : void

  • result : int

Possible faults thrown

Fault SQLException with type undefined

Fault-handling install template:

install ( SQLException => /* error-handling code */ )

Fault ConnectionError with type undefined

Fault-handling install template:

install ( ConnectionError => /* error-handling code */ )

update

Operation documentation: Updates the database and returns a single status code

  Example with SQL parameters:
  updateRequest =
      "INSERT INTO weather(city, country, data) " +
      "VALUES (:city, :country, :data)";
  updateRequest.city = City;
  updateRequest.country = Country;
  updateRequest.data = r;
  update@Database( updateRequest )( ret )

Invocation template:

update@Database( request )( response )

Request type

Type: UpdateRequest

type UpdateRequest: undefined

UpdateRequest : string

Response type

Type: int

int : int

Possible faults thrown

Fault SQLException with type undefined

Fault-handling install template:

install ( SQLException => /* error-handling code */ )

Fault ConnectionError with type undefined

Fault-handling install template:

install ( ConnectionError => /* error-handling code */ )

close

Operation documentation: Explicitly closes a database connection Per default the close happens on reconnect or on termination of the Database service, eg. when the enclosing program finishes.

Invocation template:

close@Database( request )( response )

Request type

Type: void

void : void

Response type

Type: void

void : void

connect

Operation documentation: Connects to a database and eventually closes a previous connection

  Example with HSQLDB:
  with ( connectionInfo ) {
      .username = "sa";
      .password = "";
      .host = "";
      .database = "file:weatherdb/weatherdb"; // "." for memory-only
      .driver = "hsqldb_embedded"
  };
  connect@Database( connectionInfo )( void );

Invocation template:

connect@Database( request )( response )

Request type

Type: ConnectionInfo

type ConnectionInfo: void {
    .database: string
    .password: string
    .checkConnection?: int
    .driver: string
    .port?: int
    .toLowerCase?: bool
    .host: string
    .toUpperCase?: bool
    .attributes?: string
    .username: string
}

ConnectionInfo : void

  • database : string
  • password : string
  • checkConnection : int
  • driver : string
  • port : int
  • toLowerCase : bool
  • host : string
  • toUpperCase : bool
  • attributes : string
  • username : string

Response type

Type: void

void : void

Possible faults thrown

Fault InvalidDriver with type undefined

Fault-handling install template:

install ( InvalidDriver => /* error-handling code */ )

Fault ConnectionError with type undefined

Fault-handling install template:

install ( ConnectionError => /* error-handling code */ )

Fault DriverClassNotFound with type undefined

Fault-handling install template:

install ( DriverClassNotFound => /* error-handling code */ )

Subtypes

TransactionQueryResult

type TransactionQueryResult: int { .row*: undefined }

results matching ""

    No results matching ""