K2InformaticsGmbH / oranif

Oracle OCI driver using dirty NIF
Apache License 2.0
4 stars 2 forks source link

SQLT_DAT processing #11

Closed c-bik closed 5 years ago

c-bik commented 6 years ago

Currently all SQLT_DAT fields are returned as unsigned char[7] (format defined below):

Oracle Ref: DATE

DATE

The DATE datatype can update, insert, or retrieve a date value using the Oracle internal date binary format. A date in binary format contains seven bytes, as shown in Table 3-4.

Table 3-4 Format of the DATE Datatype

Byte 1 2 3 4 5 6 7
Meaning Century Year Month Day Hour Minute Second
Example (for 30-NOV-1992, 3:17 PM) 119 192 11 30 16 18 1

The century and year bytes (bytes 1 and 2) are in excess-100 notation. The first byte stores the value of the year, which is 1992, as an integer, divided by 100, giving 119 in excess-100 notation. The second byte stores year modulo 100, giving 192. Dates Before Common Era (BCE) are less than 100. The era begins on 01-JAN-4712 BCE, which is Julian day 1. For this date, the century byte is 53, and the year byte is 88. The hour, minute, and second bytes are in excess-1 notation. The hour byte ranges from 1 to 24, the minute and second bytes from 1 to 60. If no time was specified when the date was created, the time defaults to midnight (1, 1, 1).

When you enter a date in binary format using the DATE external datatype, the database does not do consistency or range checking. All data in this format must be carefully validated before input.

Note: There is little need to use the Oracle external DATE datatype in ordinary database operations. It is much more convenient to convert DATE into character format, because the program usually deals with data in a character format, such as DD-MON-YY.

Current Implementations

https://github.com/K2InformaticsGmbH/erloci_nif/blob/b7723577261438ac600bd6671d316b120800faf4/c_src/erloci.c#L1061-L1074

Solution Alternatives

Deprecates

https://github.com/K2InformaticsGmbH/erloci_nif/blob/b7723577261438ac600bd6671d316b120800faf4/src/oci_util.erl#L24-L37

c-bik commented 5 years ago

Deprecated OCI