snippets_js
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);