SQL adaptation guide For Oracle Database 9.2, 10.x, 11.x, 12x / Data dictionary |
Informix® provides two data types to store date and time information:
ORACLE provides only the following data types to store date and time data:
Informix is able to convert quoted strings to DATE / DATETIME data if the string contains matching environment parameters (i.e. DBDATE, GL_DATETIME).
As in Informix, ORACLE can convert quoted strings to DATE or TIMESTAMP data if the contents of the string matches the NLS date format parameters (NLS_DATE_FORMAT, NLS_TIMESTAMP_FORMAT). The TO_DATE() and TO_TIMESTAMP() SQL functions convert strings to dates or timestamps, according to a given format. The TO_CHAR() SQL function allows you to convert dates or timestamps to strings, according to a given format.
Storing BDL DATE values
The ORACLE DATE type is used to store Genero BDL DATE values. However, keep in mind that the ORACLE DATE type stores also time (hh:mm:ss) information. The database interface automatically sets the time part to midnight (00:00:00) during input/output operations.
You must be very careful since manual modifications of the database might set the time part, for example:
UPDATE table SET date_col = SYSDATE
(SYSDATE is equivalent to CURRENT YEAR TO SECOND in Informix).
After this type of update, when columns have date values with a time part different from midnight, some SELECT statements might not return all the expected rows.
When fetching ORACLE DATE values into Genero BDL DATE or DATETIME variables, the date and time information is directly set for the individual date/time parts and the conversion is straight forward. But when fetching an ORACLE DATE into a CHAR or VARCHAR variable, date to string conversion occurs. Since ORACLE DATEs are equivalent of Informix DATETIME YEAR TO SECOND, the values are by default converted with the ISO format (YYYY-MM-DD hh:mm:ss), which is not the typical Informix behavior where DATEs are formatted according to the DBDATE environment variable. If your application fetches DATE values into CHAR/VARCHAR and you want to get the DBDATE conversion, you must set the following FGLPROFILE entry:
dbi.database.dbname.ora.date.ifxfetch = true
Informix DATETIME data with any precision from YEAR to SECOND is stored in ORACLE DATE columns. The database interface makes the conversion automatically. Missing date or time parts default to 1900-01-01 00:00:00. For example, when using a DATETIME HOUR TO MINUTE with the value of "11:45", the ORACLE DATE value will be "1900-01-01 11:45:00".
Informix DATETIME YEAR TO FRACTION(n) data is stored in ORACLE TIMESTAMP columns. The TIMESTAMP data type can store up to 9 digits in the fractional part, and therefore can store all precisions of Informix DATETIME.
LET stmt = "SELECT ... FROM customer WHERE creat_date >'", adate,"'"
is not portable. Use a question mark place holder instead and OPEN the cursor by USING a date:
LET stmt = "SELECT ... FROM customer WHERE creat_date > ?"