Direkt zum Inhalt

ORA-01882 with the Oracle Rust driver (or any ODPI-C)

Gespeichert von Erik Wegner am/um
Body

There is a database (Oracle 19+) with columns that save the time a record is created (column created_on) and the time a record is modified (column modified_on).

At first, you may encounter the error ORA-01805: possible error in date/time operation error. The post on stack overflow (https://stackoverflow.com/a/72609092) contains the hint to check the timezone files on both side, the server side and the client side.

Titel
Server timezone file version
select * from v$timezone_file;

On the client, change into the driver folder and call this command:

./genezi -v

If you need to use a diffrent version locally, set the environment variable export ORA_TZFILE=timezone_44.dat, without the path to the file.

ORA-01882

At a later point you may encounter the message OCI error ORA-01882: time zone region not found.

You can enable more verbose debugging output (source):

export DPI_DEBUG_LEVEL=12

The output will show that dpiStmt_fetchRows inside the C library throws the error:

ODPI [779371] 2026-07-28 11:48:20.461: fn start dpiStmt_fetchRows(0x72858c01c9c0)
ODPI [779371] 2026-07-28 11:48:20.462: OCI error ORA-01882: time zone region not found
Help: https://docs.oracle.com/error-help/db/ora-01882/ (dpiStmt_fetchRows / fetch)
ODPI [779371] 2026-07-28 11:48:20.462: fn end dpiStmt_fetchRows(0x72858c01c9c0) -> -1

There are several things to look at:

  1. Is the column using TIMESTAMP or TIMESTAMP WITH TIME ZONE?
  2. If a trigger is setting the value for the column: is it using LOCALTIMESTAMP or SYSTIMESTAMP?
  3. Which time zones are used?

    SELECT DISTINCT
      TO_CHAR(created_on, 'TZR') AS region,
      TO_CHAR(created_on, 'TZD') AS d_id,
      TO_CHAR(created_on, 'TZH:TZM') AS timezone_offset
    FROM table ORDER BY timezone_offset;

The final solution is to cast the column in the query:

SELECT CAST(created_on AS TIMESTAMP) AS created_neutral 
FROM my_table;