Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public addPrueba(element :any)
- {
- var sql = "INSERT INTO perro (edad, nombre) VALUES (:a, :b)"
- var binds = [
- { a: 1, b: "Taco" },
- { a: 23, b: "PUTABIDA" },
- ];
- var options = {
- autoCommit: true,
- bindDefs: {
- a: { type: oracledb.NUMBER },
- b: { type: oracledb.STRING, maxSize: 64 }
- }
- };
- oracledb.getConnection({
- user: "system",
- password: "51264",
- connectString: "localhost:1521/xe"
- }).then(async (connection: oracledb.IConnection) => {
- console.log("Connection finally created in constructor")
- await connection.execute(sql, binds, options).
- then((result)=>{console.log("Rows: \n", result.rowsAffected)})
- .catch((err)=>{console.error("Promise rejected - ",err)});
- connection.close().then( () => { console.log("Conection closed.") } )
- .catch((err) => { console.error(err.message) });
- }).catch((err: any) => {
- console.error(err.message);
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement