Skip to main content

Oracle

This package supports basic and advanced features of Oracle Database and Oracle Client

Network Connection needs

This integration needs network access to the server where the service is running.

See the Network access page for details about how to achieve that.

Credential configuration

To configure this credential you need the connectionString, username and password to connect to oracle DB. You can see examples of connection strings here.

Optionally you can set any of the extra config params you can see here.

Here you have an example of a filled credential configuration form in YepCode:

Oracle snippets available in editor

note

The title is the triggering text for YepCode to autocomplete the script

Integration

New integration from credential
const oraclePool = await yepcode.integration.oracle('credential-slug')
New integration from plain authentication data
const oracledb = require("oracledb");

const oraclePool = await oracledb.createPool({
username: "username",
password: "password",
connectionString: "connectionString",
...extendedOptions,
});

Close pool

Close pool
await oraclePool.close().catch(console.error);

Get connection from pool

Get connection from pool
const connection = await oraclePool.getConnection();

Close connection

Close connection
await connection.close().catch(console.error);

SELECT text only

SELECT text only (async/await)
try {
const result = await connection.execute(
`SELECT id, name, email FROM Persons`
);
result.rows.forEach(console.log);
} catch (error) {
console.error(error);
}
SELECT text only (promise)
connection
.execute(`SELECT id, name, email FROM Persons`)
.then((result) => {
result.rows.forEach(console.log);
})
.catch(console.error);

SELECT parametrized with array

SELECT parametrized with array (async/await)
try {
const result = await connection.execute(
`SELECT * FROM Persons where firstName = :0 and lastName = :1`,
["firstName", "lastName"]
);
result.rows.forEach(console.log);
} catch (error) {
console.error(error);
}
SELECT parametrized with array (promise)
connection
.execute(`SELECT * FROM Persons where firstName = :0 and lastName = :1`, [
"firstName",
"lastName",
])
.then((result) => {
result.rows.forEach(console.log);
})
.catch(console.error);

SELECT parametrized with object

SELECT parametrized with object (async/await)
try {
const result = await connection.execute(
`SELECT * FROM Persons where firstName = :firstName and lastName = :lastName`,
{
firstName: "firstName",
lastName: "lastName",
}
);
result.rows.forEach(console.log);
} catch (error) {
console.error(error);
}
SELECT parametrized with object (promise)
connection
.execute(
`SELECT * FROM Persons where firstName = :firstName and lastName = :lastName`,
{
firstName: "firstName",
lastName: "lastName",
}
)
.then((result) => {
result.rows.forEach(console.log);
})
.catch(console.error);

INSERT text only

INSERT text only (async/await)
try {
await connection.execute(
`INSERT INTO Persons values (id, 'theName', 'theEmail')`
);
await connection.commit();
} catch (error) {
console.error(error);
}
INSERT text only (promise)
connection
.execute(`INSERT INTO Persons values (id, 'theName', 'theEmail')`)
.then((result) => {
return connection.commit();
})
.catch(console.error);

INSERT parametrized with array

INSERT parametrized with array (async/await)
try {
await connection.execute(`INSERT INTO Persons values (:0, :1, :2)`, [
"1",
"name",
"email",
]);
await connection.commit();
} catch (error) {
console.error(error);
}
INSERT parametrized with array (promise)
connection
.execute(`INSERT INTO Persons values (:0, :1, :2)`, ["1", "name", "email"])
.then((result) => {
return connection.commit();
})
.catch(console.error);

INSERT parametrized with object

INSERT parametrized with object (async/await)
try {
await connection.execute(`INSERT INTO Persons values (:id, :name, :email)`, {
id: 1,
name: "name",
email: "email",
});
await connection.commit();
} catch (error) {
console.error(error);
}
INSERT parametrized with object (promise)
connection
.execute(`INSERT INTO Persons values (:id, :name, :email)`, {
id: 1,
name: "name",
email: "email",
})
.then((result) => {
return connection.commit();
})
.catch(console.error);