-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
1、What versions are you using?
oracledb version: 6.7.1
oracledb thin mode: false
oracle client version: 21.7.0.0.0
oracle server dbtimezone: +08:00
$node --version
v20.18.2
2、Describe the problem
Thick mode,To execute a stored procedure to query data, there is a column in the data whose type is DATE. Is there a way to make the value of the queried column in the +08:00 time zone or a specific time zone?
3、Include a runnable Node.js script that shows the problem.
CREATE TABLE test_date_table (
id NUMBER,
begin_time DATE
);
CREATE OR REPLACE TYPE test_date_table_record AS OBJECT (
id NUMBER,
begin_time DATE
);
CREATE OR REPLACE TYPE test_date_table_table AS TABLE OF test_date_table_record;
CREATE OR REPLACE PROCEDURE get_test_date_table_by_range (
p_start_time IN DATE,
p_end_time IN DATE,
p_data OUT test_date_table_table
) IS
BEGIN
p_data := test_date_table_table();
FOR rec IN (SELECT id, begin_time
FROM test_date_table
WHERE begin_time > p_start_time AND begin_time < p_end_time) LOOP
p_data.EXTEND;
p_data(p_data.COUNT) := test_date_table_record(rec.id, rec.begin_time);
END LOOP;
END ;const oracledb = require("oracledb");
const { to } = require("await-to-js");
let pool = {};
async function executeSql() {
let connection = await pool.getConnection();
let sql = `declare
P_START_TIME DATE;
P_END_TIME DATE;````
P_DATA TEST_DATE_TABLE_TABLE;
begin
GET_TEST_DATE_TABLE_BY_RANGE(P_START_TIME = :P_START_TIME, P_END_TIME = :P_END_TIME, P_DATA = :P_DATA);
end;`;
let p = {
P_START_TIME: { type: oracledb.DATE, val: '2025-03-11T11:00:00Z', dir: oracledb.BIND_IN },
P_END_TIME: { type: oracledb.DATE, val: '2025-03-11T13:00:00Z', dir: oracledb.BIND_IN },
P_DATA: { type: "TEST_DATE_TABLE_TABLE", dir: oracledb.BIND_OUT },
};
let [e, res] = await to(connection.execute(sql, p));
console.log(res);
await connection.commit();
await connection.close();
}
async function main() {
let config = {
username: "",
password: "",
connectString: ""
};
try {
oracledb.initOracleClient();
pool = await oracledb.createPool(config);
executeSql();
} catch(e) {
console.log("exception: ", e)
}
}
main();
Result:
{
"P_DATA": [
{
"BEGIN_TIME": "2025-03-11T04:00:00.000Z",
"ID": 13
}
}
expect result
"BEGIN_TIME": "2025-03-11T12:00:00.000+0800",
Thank you for your help.