A MLE Type Conversions
Supported conversions between JavaScript and PL/SQL, SQL, and JSON data types.
JavaScript target types include both native JavaScript types as well as SQL wrapper types. Supported SQL types are converted to the analogous JavaScript type by default where such a natural counterpart exists. If a conversion is attempted and there is no corresponding JavaScript type, conversion to a native JavaScript type is not supported and values are instead converted to the corresponding SQL wrapper type by default.
Note: MLE does not provide functionality to prevent information loss that might occur between conversions from a customized database character representation to the built-in string representation of JavaScript (UTF-16).
See Also:
-
Server-Side JavaScript API Documentation for information about using
mle-js-bindingsto change the default mappings when exchanging values between PL/SQL and JavaScript -
Server-Side JavaScript API Documentation for information on how to use
mle-js-plsqltypesto create SQL wrapper types, such asOracleNumber -
Server-Side JavaScript API Documentation for information on using
mle-js-oracledbto override the default conversions (as seen in the table Supported Mappings from SQL and PL/SQL Types to JavaScript Types) when fetching column values from aSELECTstatement
Date Conversions
JavaScript Date represents an instant (i.e., a single moment in time). Conversions can occur between the instant type Date and PL/SQL types DATE and TIMESTAMP that do not have time zone information. Conversions between instants on the JavaScript side and DATE and TIMESTAMP on the other side are handled as follows:
-
When converting a
Dateto aTIMESTAMPorDATE, the instant is converted to a timezone-aware datatime value in the current session time zone. The local datatime portion of this value is stored in the targetDATEorTIMESTAMPvalue. -
To convert a
TIMESTAMPorDATEto a timezone-awareDate, the source datetime value is interpreted to be in the session time zone and is converted into an instant according to the session time zone.
Supported Mappings from SQL and PL/SQL Types to JavaScript Types
| SQL Type | JavaScript Types (Bold Font Signifies Default) |
|---|---|
NUMBER |
numberOracleNumber |
BINARY_FLOAT |
number |
BINARY_DOUBLE |
number |
BINARY_INTEGER1 |
number |
BOOLEAN |
boolean |
VARCHAR2 |
string |
NVARCHAR2 |
string |
CHAR |
string |
NCHAR |
string |
CLOB |
OracleCLOBstring |
NCLOB |
OracleCLOBstring |
BLOB |
OracleBLOBUint8Array (TypedArray) |
RAW |
Uint8Array (TypedArray) |
DATE |
DateOracleDate |
TIMESTAMP |
DateOracleTimestamp |
TIMESTAMP WITH TIME ZONE |
DateOracleTimestampTZ |
TIMESTAMP WITH LOCAL TIME ZONE |
DateOracleTimestampTZ |
INTERVAL YEAR TO MONTH |
OracleIntervalYearToMonth |
INTERVAL DAY TO SECOND |
OracleIntervalDayToSecond |
NULL2 |
null |
JSON |
any (object, array, null)3 |
Supported Mappings from JavaScript Types to SQL Types
| JavaScript Type | SQL Type |
|---|---|
numberbooleanOracleNumber |
NUMBER |
number |
BINARY_FLOAT |
number |
BINARY_DOUBLE |
numberboolean |
BINARY_INTEGER |
numberOracleNumberboolean |
BOOLEAN |
string |
VARCHAR2 |
string |
CHAR |
string |
NCHAR |
string |
NVARCHAR2 |
stringOracleCLOB |
CLOB |
stringOracleCLOB |
NCLOB |
string |
UROWID |
Uint8ArrayOracleBlob |
BLOB |
UintArray |
RAW |
DateOracleDate |
DATE |
DateOracleTimestamp |
TIMESTAMP |
DateOracleTimestampTZ |
TIMESTAMP WITH (LOCAL) TIME ZONE |
OracleIntervalYearToMonth |
INTERVAL YEAR TO MONTH |
OracleIntervalDayToSecond |
INTERVAL DAY TO SECOND |
null |
NULL (any supported SQL type) |
numberstringbooleannullundefinedDateUint8ArrayOracleNumberOracleDateOracleTimestampOracleTimestampTZOracleIntervalYearToMonthOracleIntervalDayToSecondobject4 |
JSON5 |
-
Note that
BINARY_INTEGERis a PL/SQL type and not supported in SQL. MLE only supportsBINARY_INTEGERon PL/SQL interfaces. ↩ -
Although not technically a type, MLE converts a SQL
NULLvalue into a JavaScriptnullvalue and vice versa. This is so that JavaScript can indicate to the database that a value passed into the database is absent (for example, the return value of a function or anINbind in a SQL statement). ↩ -
See MLE JavaScript Support for JSON for details. ↩
-
JavaScript objects and arrays that do not match one of the classes listed in the table. ↩
-
See MLE JavaScript Support for JSON for details. ↩