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:

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 Date to a TIMESTAMP or DATE, 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 target DATE or TIMESTAMP value.

  • To convert a TIMESTAMP or DATE to a timezone-aware Date, 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.

Table A-1 Supported Mappings from SQL and PL/SQL Types to JavaScript Types

SQL Type JavaScript Types (Bold Font Signifies Default)

NUMBER

number

OracleNumber

BINARY_FLOAT

number

BINARY_DOUBLE

number

BINARY_INTEGERFoot 1

number

BOOLEAN

boolean

VARCHAR2

string

NVARCHAR2

string

CHAR

string

NCHAR

string

CLOB

OracleCLOB

string

NCLOB

OracleCLOB

string

BLOB

OracleBLOB

Uint8Array (TypedArray)

RAW

Uint8Array (TypedArray)

DATE

Date

OracleDate

TIMESTAMP

Date

OracleTimestamp

TIMESTAMP WITH TIME ZONE

Date

OracleTimestampTZ

TIMESTAMP WITH LOCAL TIME ZONE

Date

OracleTimestampTZ

INTERVAL YEAR TO MONTH

OracleIntervalYearToMonth

INTERVAL DAY TO SECOND

OracleIntervalDayToSecond

NULLFoot 2

null

JSON

any (object, array, null)Foot 3

Footnote 1 Note that BINARY_INTEGER is a PL/SQL type and not supported in SQL. MLE only supports BINARY_INTEGER on PL/SQL interfaces.

Footnote 2 Although not technically a type, MLE converts a SQL NULL value into a JavaScript null value 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 an IN bind in a SQL statement).

Footnote 3 See MLE JavaScript Support for JSON for details

Table A-2 Supported Mappings from JavaScript Types to SQL Types

JavaScript Type SQL Type

number

boolean

OracleNumber

NUMBER

number

BINARY_FLOAT

number

BINARY_DOUBLE

number

boolean

BINARY_INTEGER

number

OracleNumber

boolean

BOOLEAN

string

VARCHAR2

string

CHAR

string

NCHAR

string

NVARCHAR2

string

OracleCLOB

CLOB

string

OracleCLOB

NCLOB

string

UROWID

Uint8Array

OracleBlob

BLOB

UintArray

RAW

Date

OracleDate

DATE

Date

OracleTimestamp

TIMESTAMP

Date

OracleTimestampTZ

TIMESTAMP WITH (LOCAL) TIME ZONE

OracleIntervalYearToMonth

INTERVAL YEAR TO MONTH

OracleIntervalDayToSecond

INTERVAL DAY TO SECOND

null

NULL (any supported SQL type)

number

string

boolean

null

undefined

Date

Uint8Array

OracleNumber

OracleDate

OracleTimestamp

OracleTimestampTZ

OracleIntervalYearToMonth

OracleIntervalDayToSecond

objectFoot 4

JSONFoot 5

Footnote 4 JavaScript objects and arrays that do not match one of the classes listed above

Footnote 5 See MLE JavaScript Support for JSON for details

OSZAR »