-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CURRENT_TIMESTAMP
returns offset in time despite specifying timezone =
in dbConnect()
with Oracle
#681
Comments
Umh, this seems to work as documented... From Oracle's documentation:
And from Same reprex than above but with library(DBI)
Sys.setenv(TZ = "Europe/Paris")
Sys.time()
# [1] "2023-12-15 11:36:37 CET"
query <- "SELECT SYSDATE AS DTE FROM DUAL;"
conn <- dbConnect(odbc::odbc(),
dsn = "xxx",
timezone = "Europe/Paris",
timezone_out = "Europe/Paris")
dbGetQuery(conn, query)$DTE
# [1] "2023-12-15 11:36:38 CET"
dbDisconnect(conn)
Sys.setenv(ORA_SDTZ = "Europe/Paris")
conn <- dbConnect(odbc::odbc(),
dsn = "xxx",
timezone = "Europe/Paris",
timezone_out = "Europe/Paris")
dbGetQuery(conn, query)$DTE
# "2023-12-15 11:36:38 CET"
dbDisconnect(conn) So finally the question is: should |
Interesting... I can't reproduce that offset in On Linux with Posit Pro Driver, like your setup: Sys.getenv(c("TZ", "ORA_SDTZ"))
#> TZ ORA_SDTZ
#> "" ""
library(odbc)
con <- dbConnect(odbc(), dsn = "ProOracle",
timezone = "America/Chicago", timezone_out = "America/Chicago")
Sys.time()
#> [1] "2024-07-17 15:51:28 CDT"
query <- "SELECT CURRENT_TIMESTAMP AS DTE FROM DUAL;"
dbGetQuery(con, query)$DTE
#> [1] "2024-07-17 15:51:28 CDT" dbGetInfo(con)
On macOS with Oracle's driver: Sys.getenv(c("TZ", "ORA_SDTZ"))
#> TZ ORA_SDTZ
#> "" ""
library(odbc)
con <- dbConnect(odbc(), dsn = "Oracle", `Service Name` = "orclpdb1",
DBQ = "db", UID = "test", PWD = "odbc",
timezone = "America/Chicago", timezone_out = "America/Chicago")
Sys.time()
#> [1] "2024-07-17 15:53:18 CDT"
query <- "SELECT CURRENT_TIMESTAMP AS DTE FROM DUAL;"
dbGetQuery(con, query)$DTE
#> [1] "2024-07-17 15:53:18 CDT" dbGetInfo(con)
Setting There have been a few Pro Driver releases since 2.0.2.1002. Could you install an updated driver and confirm that that doesn't address the issue? |
I don't have the rights to install anything myself on our R server. My IT department has been planning to upgrade the drivers "soon" since last year... I'll test and report back when they do. FWIW, with an (outdated) Oracle driver on Linux I get: library(DBI)
con <- dbConnect(odbc::odbc(), dsn = "zzz")
dbGetQuery(con, "select current_timestamp as dte from dual")
# Erreur : nanodbc/nanodbc.cpp:1769: 00000: [Oracle][ODBC][Ora]Optional feature not implemented.
# <SQL> 'select current_timestamp as dte from dual'
dbDisconnect(con) DatabasedbGetInfo(conn)
# $dbname
# [1] ""
#
# $dbms.name
# [1] "Oracle"
#
# $db.version
# [1] "19.00.0000"
#
# $username
# [1] ""
#
# $host
# [1] ""
#
# $port
# [1] ""
#
# $sourcename
# [1] "zzz"
#
# $servername
# [1] "zzz"
#
# $drivername
# [1] "SQORA32.DLL"
#
# $odbc.version
# [1] "03.52"
#
# $driver.version
# [1] "12.01.0020"
#
# $odbcdriver.version
# [1] "03.52"
#
# $supports.transactions
# [1] TRUE
#
# $getdata.extensions.any_column
# [1] TRUE
#
# $getdata.extensions.any_order
# [1] TRUE
#
# attr(,"class")
# [1] "Oracle" "driver_info" "list" |
Haha, heard! Thanks for the quick response @ThomasSoeiro, we'll leave this open a bit longer in case you're able to see if a newer Pro Driver resolves the issue. |
Using Oracle,
CURRENT_TIMESTAMP
returns a date-time with an offset in time despite specifyingtimezone =
indbConnect()
:ORA_SDTZ
must be set to get the correct result:OTOH, specifying
timezone =
indbConnect()
is sufficient to get correct date-times usingTIMESTAMP
:Database
Session Info
The text was updated successfully, but these errors were encountered: