Skip to content

Data Type Support

db2-node maps Db2 wire values into plain JavaScript values. The Rust protocol layer recognizes Db2 for z/OS built-in scalar types, including the LOB families documented by IBM: CLOB, DBCLOB, and BLOB. See IBM's Data types in Db2 for z/OS reference for the server-side type definitions.

JavaScript Mappings

Db2 for z/OS typeJavaScript valueNotes
SMALLINTnumber16-bit signed integer
INTEGERnumber32-bit signed integer
BIGINTnumberReturned through Node's numeric path; use casts to character/decimal if exact JS-safe integer handling is required above Number.MAX_SAFE_INTEGER.
FLOAT(n), REAL, DOUBLEnumberNon-finite wire values are normalized to 0 at the JS boundary.
DECIMAL, NUMERICstringPreserves precision and scale.
DECFLOAT(16), DECFLOAT(34)stringPreserves decimal floating-point text.
CHAR, VARCHAR, long character datastringCCSID-aware decoding for UTF-8 and common EBCDIC z/OS flows.
GRAPHIC, VARGRAPHICstringPublic typeName is shown as CHAR(n) / VARCHAR(n) with db2TypeName preserving GRAPHIC(n) / VARGRAPHIC(n).
CLOBstringz/OS external LOB materialization is handled by the production cleanup modes.
DBCLOBstringDecoded as character data, with db2TypeName: "DBCLOB" in metadata.
BINARY, VARBINARYBufferBinary values are returned as Node buffers.
BLOBBufferInline and materialized BLOB values are returned as Node buffers.
DATEstringDb2 text form, for example 2026-05-08.
TIMEstringDb2 text form.
TIMESTAMP(p) WITHOUT TIME ZONEstringDescriptor length controls precision.
TIMESTAMP(p) WITH TIME ZONEstringReturned as Db2's text form when the server exposes it through DRDA timestamp metadata.
ROWIDstringHex string such as 0xDEADBEEF....
XMLstringXML document/content text.
BOOLEANbooleanSupported when the server supports Boolean columns.
Distinct typesSource type mappingDb2 distinct types use the representation of their source built-in type.

All nullable columns return null when the server value is SQL NULL.

Parameters

Parameterized queries use server-provided input descriptors when Db2 supplies them. When the driver must infer a parameter type, JavaScript values map as follows:

JavaScript inputInferred Db2 value
number integer in 32-bit rangeINTEGER
larger integer numberBIGINT
fractional numberDOUBLE
stringVARCHAR
booleanBOOLEAN
nullSQL NULL when Db2 provides input metadata
Buffer, Uint8Array, or number arraybinary value suitable for BINARY, VARBINARY, or BLOB parameters

For exact DECIMAL, DECFLOAT, DATE, TIME, TIMESTAMP, XML, and LOB parameter typing, cast the parameter in SQL:

ts
await client.query('VALUES CAST(? AS DECFLOAT(34))', ['123456789.00001'])
await client.query('INSERT INTO docs (body) VALUES (CAST(? AS CLOB(1M)))', [xmlText])
await client.query('INSERT INTO files (payload) VALUES (CAST(? AS BLOB(1M)))', [buffer])

z/OS LOB Safety

For Db2 for z/OS, LOB queries can leave external data frames queued after the requested rows are materialized. The default production mode disconnects and warm-replaces a connection when cleanup cannot be verified. Active close mode (DB2_ZOS_LOB_CLOSE_AFTER_MATERIALIZE=1) sends CLSQRY, drains remaining EXTDTA, and only reuses the socket after Db2 acknowledges the close.

Aggregate or scalar queries that filter CLOB-like text with LIKE or NOT LIKE use a large statement package EXCSQLSTT path by default on Db2 for z/OS, even when the result itself is not a LOB. Set DB2_ZOS_LIKE_PREDICATE_EXCSQLSTT=0 only while diagnosing package-specific behavior.

See Getting Started for the production mode tradeoffs.

Source Coverage

This matrix is based on the IBM Db2 for z/OS 12 data type categories: numeric, character, graphic, binary, LOB, datetime, row ID, XML, distinct types, and nullable values. User-defined array types are not exposed as ordinary scalar row values by this driver; use SQL to unnest or serialize arrays before returning them to Node.js.

Released under the MIT License.