gizlang:odbc
Thin ODBC driver boundary. SQL semantics and planning belong to the data layer. Exact text/binary cells, bounded forward cursors, explicit transactions, no retries.
import * as Odbc from "gizlang:odbc";Types
OdbcError
type OdbcError = { sqlstate: string; code: i64; message: string; }An ODBC failure: its SQLSTATE, native code and message.
sqlstate:stringcode:i64message:string
Column
type Column = { name: string; sqlType: i64; precision: i64; scale: i64; nullable: bool; }A result column of an ODBC statement: its name, SQL type, precision, scale and whether it may be NULL.
name:stringsqlType:i64precision:i64scale:i64nullable:bool
Parameter
type Parameter = { sqlType: i64; precision: i64; scale: i64; binary: bool; value: Option<bytes>; }A parameter of an ODBC statement: its SQL type, precision, scale, whether it is binary, and its value (none for NULL).
sqlType:i64precision:i64scale:i64binary:boolvalue:_gizlang_sdk_core.Option<bytes>
Cell
type Cell = | { kind: "null"; } | { kind: "text"; value: string; } | { kind: "binary"; value: bytes; }One cell of an ODBC result: NULL, text or binary.
nulltextbinary
Page
type Page = { rows: Vec<Vec<Cell>>; done: bool; }A page of ODBC result rows, and whether it is the last.
rows:Vec<Vec<gizlang_odbc.Cell>>done:bool
Capabilities
type Capabilities = { write: bool; transaction: bool; cancel: bool; }What an ODBC data source supports: writes, transactions and cancelling a statement.
write:booltransaction:boolcancel:bool
Connection
type ConnectionA connection to an ODBC data source.
Opaque: create and use it through this module's functions.
Cursor
type CursorAn open result of an ODBC statement, read page by page.
connection:gizlang_odbc.Connectioncolumns:Vec<gizlang_odbc.Column>cellBytes:i64
Functions
open
function open(sys: System, connectionString: string): Connection throws OdbcErrorDriver-specific connection strings remain at this explicit external boundary.
Effects: fail, read, write, io.
Methods
Connection.prepare
function Connection.prepare(self: Connection, sql: string, params: Vec<Parameter>, cellBytes: i64): Cursor throws OdbcErrorSQL prepared once with its parameter types PARAMS; each result cell is read into at most CELLBYTES bytes.
Effects: fail, read, write, io.
Connection.capabilities
function Connection.capabilities(self: Connection): Capabilities throws OdbcErrorDriver-reported facts, not abilities inferred from the connection's spelling.
Effects: fail, read, io.
Cursor.poll
function Cursor.poll(self: Cursor, rows: i64, bytes: i64): Page throws OdbcErrorAdmission precedes SQLFetch; this page never retains more than rowBytes * rows.
Effects: fail, read, write, io.
Cursor.affected
function Cursor.affected(self: Cursor): i64 throws OdbcErrorThe number of rows that the statement changed (SQLRowCount).
Effects: fail, read, io.
Cursor.cancel
function Cursor.cancel(self: Cursor): bool throws OdbcErrorAsks the driver to stop the statement that runs (SQLCancel).
Effects: fail, read, io.
Cursor.close
function Cursor.close(self: Cursor): boolFrees the statement. It does nothing after the first call.
Effects: fail, read, write, io.
Connection.begin
function Connection.begin(self: Connection): bool throws OdbcErrorStarts a transaction: autocommit is off until end.
Effects: fail, read, write, io.
Connection.end
function Connection.end(self: Connection, commit: bool): bool throws OdbcErrorEnds the transaction: it commits when COMMIT, else rolls back; autocommit is on again.
Effects: fail, read, write, io.
Connection.close
function Connection.close(self: Connection): boolDisconnects and frees the connection. It does nothing after the first call.
Effects: fail, read, write, io.