Skip to main content

Reference

 

OutSystems

RuntimePublic.Db API

The RuntimePublic.Db API provides functionality to allow you to integrate with your external databases.

With this API you enable your extension modules to call the databases configured in the environment management console. It is, by default, imported to your extension project when you create it in Integration Studio. To use this API you only need to reference its classes in your extension's project.

It is available for both .NET and Java stacks:

  • .NET: under the OutSystems.RuntimePublic.Db namespace and is fully documented;
  • Java: under the outsystems.runtimepublic.db package and is fully documented.

Classes

Name Description
Command
(.NET, Java)
Represents a command to execute queries.
CommittableTransaction
(.NET, Java)
Represents a transaction that needs to be explicitly managed using commit and roll back operations. Can be used for selecting, inserting, updating, and deleting data.
Connection
(.NET, Java)
Represents a connection to a database.
DatabaseAccess
(.NET, Java)
Creates DatabaseProvider instances to access a database.
DatabaseProvider
(.NET, Java)
Provides access to a specific database.
DataParameter
(.NET, Java)
Represents the query parameters associated with a command.
RequestTransaction
(.NET, Java)
Represents the transaction that is automatically managed by the platform. The transaction starts at the beginning of the web request, and is committed when the response is sent to the client. Can be used for selecting, inserting, updating, and deleting data.
SqlHelper
(.NET, Java)
Functions to assist on the manipulation of SQL statements members.

API Reference (.NET)

Command

Represents a command to execute queries.

Methods

Name Description
DataParameter CreateParameter(string name, DbType type, object value) Adds a parameter to the command with a given type and value. The parameter value is modified to a compatible database value.
DataParameter CreateParameter(string name) Adds a parameter to the command. The parameter value is modified to a compatible database value.
void Dispose() Frees the resources used by this object.
int ExecuteNonQuery() Executes the command and returns the number of rows affected.
IDataReader ExecuteReader() Executes the command text returning the resulting System.Data.IDataReader.
object ExecuteScalar() Executes the query, and returns the first column of the first row in the resultset returned by the query. Extra columns or rows are ignored.
Connection GetConnection() Returns the database connection associated to this command.
IDbCommand GetDriverCommand() Returns the native command object used by the stack in which the application is running.
DataParameter GetParameter(string columnName) Gets the parameter with the specified name.

Members

Name Description
string CommandText Gets or sets the SQL statements to execute.
int CommandTimeout Gets or sets the command execution timeout.

CommittableTransaction

Represents a transaction that needs to be explicitly managed using commit and roll back operations. Can be used for selecting, inserting, updating, and deleting data.

Methods

Name Description
void Close() Rolls back a transaction from a pending state and closes the transaction.
void Commit() Commits the transaction.
Command CreateCommand(string sql) Creates a command to be executed in this transaction.
Command CreateCommand() Creates an empty command to be executed in this transaction.
void Dispose() Releases the transaction and frees the resources used by this object.
Connection GetConnection() Gets the database connection associated with this transaction.
IDbTransaction GetDriverTransaction() Returns the native transaction object used by the stack in which the application is running. It allows to reuse existing code that receives a native transaction object as parameter.
void Rollback() Rolls back a transaction from a pending state.

Connection

Represents a connection to a database.

Methods

Name Description
CommittableTransaction BeginReadUncommittedTransaction() Creates a OutSystems.RuntimePublic.Db.CommittableTransaction with the transaction isolation level set to read uncommitted.
CommittableTransaction BeginTransaction() Creates a OutSystems.RuntimePublic.Db.CommittableTransaction with the transaction isolation level set to read committed.
void Close() Closes the connection to the database.
Command CreateCommand(string sql) Creates a command that does not have an associated transaction.
Command CreateCommand() Creates an empty command that does not have an associated transaction.
void Dispose() Closes the connection and frees the resources used by this object.
IDbConnection GetDriverConnection() Returns the native connection object used by the stack in which the application is running.  It allows to reuse existing code that receives a native connection object as parameter.
bool IsClosed() Checks if the connection is closed.

DatabaseAccess

Creates DatabaseProvider instances to access a database.

Methods

Name Description
DatabaseProvider ForDatabase(string databaseName) Returns a database provider for a given database catalog or schema. Use it to access data managed by applications that are configured to use this database.
DatabaseProvider ForExternalDatabase(string connectionName) Returns a database provider for a specific external database connection. Use it to access data managed by external systems.
DatabaseProvider ForRunningApplication() Returns a database provider to access the database of the currently running application. Use it to access data managed by the currently running application, or other applications sharing the same database.
DatabaseProvider ForSystemDatabase() Returns a database provider to access the system database. Use it to query the platform metamodel.

DatabaseProvider

Provides access to a specific database.

Methods

Name Description
CommittableTransaction GetCommitableTransaction() Returns a new transaction that needs to be managed explicitly using a commit or roll back.
RequestTransaction GetRequestTransaction() Returns the transaction that starts at the beginning of the web request and is committed when the response is sent to the client. This transaction cannot be committed or rolled back inside extensions.

Members

Name Description
SqlHelper SqlHelper Returns an SqlHelper instance targeted at the manipulation of SQL statements members.
int CommandTimeout Gets or sets the command execution timeout.

DataParameter

Represents the query parameters associated with a command.

Methods

Name Description
IDbDataParameter GetDriverParameter() Returns the native parameter object used by the stack in which the application is running.

Members

Name Description
DbType DbType Gets or sets the database type.
int Size Sets the size of the parameter.
object Value Gets or sets the parameter value.

RequestTransaction

Represents the transaction that is automatically managed by the platform. The transaction starts at the beginning of the web request, and is committed when the response is sent to the client. Can be used for selecting, inserting, updating, and deleting data.

Methods

Name Description
Command CreateCommand(string sql) Creates a command to be executed in this transaction.
Command CreateCommand() Creates an empty command to be executed in this transaction.
void Dispose() Releases the transaction and frees the resources used by this object.
Connection GetConnection() Gets the database connection associated with this transaction.
IDbTransaction GetDriverTransaction() Returns the native transaction object used by the stack in which the application is running. It allows to reuse existing code that receives a native data object as parameter.
void Release() Checks if the transaction exists, and frees the resources associated with it. Since this transaction is automatically managed by the platform, no commit or rollback operations are performed when releasing the transaction.

SqlHelper

Functions to assist on the manipulation of SQL statements members.

Methods

Name Description
string EscapeIdentifier(string identifier) Escapes an identifier so it can be used in an query.
string PrefixParam(string paramName) Prefixes a parameter name in order to be used as a placeholder in a query or to be used as the defacto parameter name when creating command parameters.

API Reference (Java)

Command

Represents a command to execute queries.

Methods

Name Description
DataParameter createParameter(String name, int type, Object value) Adds a parameter to the command with a given type and value. The parameter value is modified to a compatible database value.
DataParameter CreateParameter(String name) Adds a parameter to the command. The parameter value is modified to a compatible database value.
void dispose() Frees the resources used by this object.
int executeNonQuery() Executes the command and returns the number of rows affected.
OSResultSet executeReader() Executes the command text returning the resulting outsystems.hubedition.util.OSResultSet.
Object executeScalar() Executes the query, and returns the first column of the first row in the resultset returned by the query. Extra columns or rows are ignored.
String getCommandText() Gets the SQL statements to execute.
int getCommandTimeout() Gets the command execution timeout.
Connection getConnection() Returns the database connection associated to this command.
ADOCommand getDriverCommand() Returns the native command object used by the stack in which the application is running.
DataParameter getParameter(String columnName) Gets the parameter with the specified name.
void setCommandText() Sets the SQL statements to execute.
void setCommandTimeout() Sets the command execution timeout.

CommittableTransaction

Represents a transaction that needs to be explicitly managed using commit and roll back operations. Can be used for selecting, inserting, updating, and deleting data.

Methods

Name Description
void close() Rolls back a transaction from a pending state and closes the transaction.
void commit() Commits the transaction.
Command createCommand(String sql) Creates a command to be executed in this transaction.
Command createCommand() Creates an empty command to be executed in this transaction.
void dispose() Releases the transaction and frees the resources used by this object.
Connection getConnection() Gets the database connection associated with this transaction.
ADOTransaction getDriverTransaction() Returns the native transaction object used by the stack in which the application is running. It allows to reuse existing code that receives a native transaction object as parameter.
void rollback() Rolls back a transaction from a pending state.

Connection

Represents a connection to a database.

Methods

Name Description
CommittableTransaction beginReadUncommittedTransaction() Creates a outsystems.runtimepublic.db.CommittableTransaction with the transaction isolation level set to read uncommitted.
CommittableTransaction beginTransaction() Creates a outsystems.runtimepublic.db.CommittableTransaction with the transaction isolation level set to read committed.
void close() Closes the connection to the database.
Command createCommand(String sql) Creates a command that does not have an associated transaction.
Command createCommand() Creates an empty command that does not have an associated transaction.
void dispose() Closes the connection and frees the resources used by this object.
Connection GetDriverConnection() Returns the native connection object used by the stack in which the application is running.  It allows to reuse existing code that receives a native connection object as parameter.
boolean isClosed() Checks if the connection is closed.

DatabaseAccess

Creates DatabaseProvider instances to access a database.

Methods

Name Description
DatabaseProvider forDatabase(String databaseName) Returns a database provider for a given database catalog or schema. Use it to access data managed by applications that are configured to use this database.
DatabaseProvider forExternalDatabase(String connectionName) Returns a database provider for a specific external database connection. Use it to access data managed by external systems.
DatabaseProvider forRunningApplication() Returns a database provider to access the database of the currently running application. Use it to access data managed by the currently running application, or other applications sharing the same database.
DatabaseProvider forSystemDatabase() Returns a database provider to access the system database. Use it to query the platform metamodel.

DatabaseProvider

Provides access to a specific database.

Methods

Name Description
CommittableTransaction getCommitableTransaction() Returns a new transaction that needs to be managed explicitly using a commit or roll back.
RequestTransaction getRequestTransaction() Returns the transaction that starts at the beginning of the web request and is committed when the response is sent to the client. This transaction cannot be committed or rolled back inside extensions.
SqlHelper getSqlHelper() Returns an sqlHelper instance targeted at the manipulation of SQL statements members

DataParameter

Represents the query parameters associated with a command.

Methods

Name Description
int getDbType() Gets the database type.
ADOParameter getDriverParameter() Returns the native parameter object used by the stack in which the application is running.
int getSize() Gets the size parameter value.
Object getValue() Gets the parameter value.
void setDbType(int value) Sets the database type.
void setSize(int value) Sets the size of the parameter.
void setValue(Object value) Sets the parameter value.

RequestTransaction

Represents the transaction that is automatically managed by the platform. The transaction starts at the beginning of the web request, and is committed when the response is sent to the client. Can be used for selecting, inserting, updating, and deleting data.

Methods

Name Description
Command createCommand(String sql) Creates a command to be executed in this transaction.
Command createCommand() Creates an empty command to be executed in this transaction.
void dispose() Releases the transaction and frees the resources used by this object.
Connection getConnection() Gets the database connection associated with this transaction.
ADOTransaction getDriverTransaction() Returns the native transaction object used by the stack in which the application is running. It allows to reuse existing code that receives a native data object as parameter.
void release() Checks if the transaction exists, and frees the resources associated with it. Since this transaction is automatically managed by the platform, no commit or rollback operations are performed when releasing the transaction.

SqlHelper

Functions to assist on the manipulation of SQL statements members.

Methods

Name Description
String escapeIdentifier(String identifier) Escapes an identifier so it can be used in an query.
String prefixParam(String paramName) Prefixes a parameter name in order to be used as a placeholder in a query or to be used as the defacto parameter name when creating command parameters.
  • Was this article helpful?