Skip to main content
Roberty Studio
RPADatabase

Oracle

Oracle

The Oracle module is responsible for connecting to an Oracle DBMS, performing queries and handling the results inside the robot.

Methods​

connection​

Method responsible for creating a connection with an Oracle database.

js
const connection = await Database.Oracle.connection["v1_0_0"]({
user: "userRoberty",
password: "robertyBD123",
connectString: "localhost:1521/robertyBD",
connectTimeout: 10,
queryTimeout: 60,
})

Required parameters​

  • user: String - expects the Oracle database user.
  • password: String - expects the user's password.
  • connectString: String - expects the Oracle connect string (e.g. localhost:1521/robertyBD).

Optional parameters​

  • connectTimeout: Number - maximum time, in seconds, to wait for the server to accept the connection.
  • queryTimeout: Number - default time limit, in seconds, for every query run on this connection. 0 = no limit.

Return​

Returns the open connection, which must be stored in a variable (like connection in the example) and provided in the connection parameter of the other methods.

Version v2_0_0 of this method receives, instead of user, password and connectString, the connectionId of a connection configured in the workspace (Workspace → Connections), besides the same connectTimeout and queryTimeout:

js
const connection = await Database.Oracle.connection["v2_0_0"]({
connectionId: "id-of-the-connection-configured-in-the-workspace",
connectTimeout: 10,
queryTimeout: 60,
})

close​

Method responsible for closing an open connection with an Oracle database.

js
await Database.Oracle.close["v1_0_0"]({
connection: connection,
})

Required parameters​

  • connection: Return of the connection action - expects the connection obtained through the connection action.

Optional parameters​

This action has no optional parameters.

Return​

This action has no returns.

query​

Method responsible for performing a query directly in the database through the connection obtained by the connection action.

js
const query = await Database.Oracle.query["v1_0_0"]({
query: `SELECT * FROM tabela;`,
connection: connection,
timeout: 120
})

Required parameters​

  • connection: Return of the connection action - expects the connection obtained through the connection action.
  • query: String - expects a string with the query to be performed.

Optional parameters​

  • timeout: Number - time limit, in seconds, for this query. When omitted, the connection's queryTimeout applies. 0 = no limit. When the limit is reached, the promise rejects with an error whose message starts with Timeout. When neither timeout nor the connection's queryTimeout is provided, there is no limit.

Return​

The constant or variable created, such as the query of the example shown earlier, receives a value of the Object type. The object returned has the following properties:

  • query.query: String - returns the query that was used.
  • query.results: Array - returns every result obtained with the query.
  • query.resultsCount: Number - returns the number of rows obtained in the result.