I have a NodeJS app and I am using oracledb npm package to send data to oracle db. I have table that looks like this:
EVENT_ID NUMBER(38,0)
EVENT_TIMESTAMP TIMESTAMP(6)
EVENT_TYPE NUMBER(38,0)
I built the query and set the binds but I am not able to get the timestamp binding working. This is how the query looks:
sql = `INSERT INTO MY_TABLE(
EVENT_ID,
EVENT_TIMESTAMP,
EVENT_TYPE
)
VALUES(
${event.id},
'${new Date(event.isoDate).slice(0, 19).replace("T", " ")}', //Convert iso date to MS SQL format
${event.type}
)`;
And here are the bindings:
export const EventsOracleBinds = {
EVENT_ID: { type: oracledb.DB_TYPE_NUMBER, maxSize: 38 },
EVENT_TIMESTAMP: { type: oracledb.DB_TYPE_TIMESTAMP },
EVENT_TYPE: { type: oracledb.DB_TYPE_NUMBER, maxSize: 38 },
};
If I console.log(sql) and copy-paste it in MSSQL, it is able to insert the row.
Any thoughts on what I might be doing wrong in my Node application?