Closed rkboyce closed 8 years ago
Looks like some type of casting needs to be added that will make sqlRender translate it properly to Oracle.
@schuemie , What's the appropriate syntax for SqlRender that will translate to to_date() (or equivalent for Oracle?)
Thanks!
Ughhh, yes, literal dates are a bit of a mess. First of all, I 'standardized' on this date format: 'YYYYMMDD', so '20160101' in this case.
Second, you want to use
CAST('20160101' AS DATE)
as the input to SqlRender for it to translate correctly (on Oracle) to
TO_DATE('20160101', 'yyyymmdd')
Perhaps a cleaner way would be to be explicit about the date format using DATE_FROM_PARTS
:
DATE_FROM_PARTS(2016,1,1)
which will translate (on Oracle) to:
TO_DATE(TO_CHAR(2016,'0000')||'-'||TO_CHAR(1,'00')||'-'||TO_CHAR(1,'00'), 'YYYY-MM-DD')
@schuemie , can we standardize on the date format yyyy-mm-dd. That's the mssql format that they adopted for using string literals, so can we just tell oracle to expect that format, and in our own 'ohdsi-sql' queries, any time we specify a standard date, we use yyyy-mm-dd format? I only suggest this beacuse if you run select CAST('20160101' AS DATE) you get 2016-01-01 as the result...so just suggesting using the native format.
But, for this problem I think your suggestion to use date_from_parts() is better in that it's more explicit, but the pain is I have to find all places where dates are used and change the sql query to use that function...but, it is the better way, so I'll make that change.
As far as the standard date format that sqlrender uses, I'll leave that entirely up to you.
-Chris
Ahah! But I was clever and I put all date-to-sql translation into a common function. So this should be trivial.
@rkboyce , I will push a fix to master, and close this issue once pushed. You will need to pull latest version of WebAPI once this is done (this is a WebAPI fix, not a CIrce fix, but reporting this under CIRCE is totally fine).
-Chris
Hi,
I set up the multihome WebAPI for the first time today using CDM and OHDSI schemas in our Oracle DBMS. Doing various tests with Circe and ran into a possible problem. When generating a cohort that uses any kind of specific date restriction, the generated SQL triggers ORA-01861: literal does not match format string. See a specific example below. I found this did run after wrapping dates with to_date() e.g.,
QUERY THAT FAILED: