0
我有一個帶有時間戳字段的Oracle數據庫。什麼是正確的SQL代碼插入時間戳到這個領域?如何使用Node-Oracle驅動程序插入時間戳?
SQL CLASSIC:
insert into test (time_of_add_doc)
values (to_timestamp('22/12/17 09:00:00','DD/MM/RR HH24:MI:SS');
(1)一行添加成功!
我想連接到我的數據庫(成功)
oracledb.getConnection({
user: 'ctrm',
password: 'ctrm',
connectString: "localhost/sig"
},
function (err, connection) {
if (err) {
console.error(err.message);
return;
}
console.log('Connection was successful!'); //Get Connection success
connection.execute(
"INSERT INTO test VALUES (:time_of_add_doc)", {
time_of_add_doc: ('22/12/17 09:00:00','DD/MM/RR HH24:MI:SS'),
},
function (err, result) {
if (err)
console.error(err.message);
else
console.log("Rows inserted " + result.rowsAffected);
});
非常感謝!工作的 –
沒問題@Anis;我很高興!你需要尾隨的逗號嗎?我從來沒有真正使用JS。如果這解決了您的問題,請點擊複選標記,考慮[接受](https://meta.stackexchange.com/q/5234/179419)。這向更廣泛的社區表明,您已經找到了解決方案,併爲答覆者和您自己提供了一些聲譽。沒有義務這樣做。 – Ben