UNPKG

ibm_db

Version:

IBM DB2 and IBM Informix bindings for node

117 lines (116 loc) 6.84 kB
import { ConnStr } from './ConnStr'; import { DescribeObject } from './DescribeObject'; import { ODBC } from './ODBC'; import { ODBCConnection } from './ODBCConnection'; import { ODBCResult, SQLResults } from './ODBCResult'; import { ODBCStatement } from './ODBCStatement'; import { Options } from './Options'; import { Pool } from './Pool'; import { FetchMode } from './attributes'; import { DB2Error } from './DB2Error'; import { Readable } from 'node:stream'; export interface SQLCA { sqlstate: string; sqlcode: number; } export interface SQLParamObject { ParamType: 'INPUT' | 'OUTPUT' | 'INOUT' | 'FILE' | 'ARRAY' | 1 | 2 | 3 | 4; CType?: 'CHAR' | 'BINARY' | 'DOUBLE' | 'DECIMAL' | 'INTEGER' | 'BIGINT' | 1 | -2 | 8 | 4 | -25; SQLType?: 'DOUBLE' | 'DECIMAL' | 'BIGINT' | 'CHAR' | 'BINARY' | 'BLOB' | 'CLOB' | 'DBCLOB' | 'XML' | 'GRAPHIC' | 'VARGRAPHIC' | 'LONGGRAPHIC' | 8 | 3 | -5 | 1 | -2 | -98 | -99 | -350 | -370 | -95 | -96 | -97; DataType?: number | string; Data: number | '' | Buffer; Length: number; } export type SQLParam = string | number | null | SQLParamObject; export interface SQLQuery { sql: string; params?: SQLParam[]; noResults?: boolean; ArraySize?: number; } export interface SQLExecuteFileParam { sql: string; delimiter: string; outputfile: string; } export type CloseOption = number & { __TYPE__: 'CloseOption'; }; export declare class Database { odbc: ODBC; fetchMode: FetchMode | null; connected: boolean; connectTimeout: number | null; systemNaming?: boolean; codeSet: string | null; mode: string | null; pool: Pool | null; connStr: string | null; conn?: ODBCConnection; SQL_CLOSE: CloseOption; SQL_DROP: CloseOption; SQL_UNBIND: CloseOption; SQL_RESET_PARAMS: CloseOption; SQL_DESTROY: CloseOption; FETCH_ARRAY: FetchMode; FETCH_OBJECT: FetchMode; constructor(options?: Options); open(connStr: string | ConnStr): Promise<void>; open(connStr: string | ConnStr, cb: (err?: DB2Error) => void): null; openSync(connStr: string | ConnStr): true; close(cb: (err: null | Error) => void): false; close(): Promise<true>; closeSync(): true | undefined; checkConnectionError(error: Error): void; query(query: string, params: SQLParam[], cb: (err: Error, outputParam: SQLResults, sqlca: SQLCA) => void): false; query(query: string | SQLQuery, cb: (err: Error, outputParam: SQLResults, sqlca: SQLCA) => void): false; query(query: string | SQLQuery, params?: SQLParam[]): Promise<SQLResults>; queryResult(query: string | SQLQuery, params: SQLParam[], cb: (err: Error, res?: null | ODBCResult, outputParam?: SQLResults) => void): false; queryResult(query: string | SQLQuery, cb: (err: Error, res?: null | ODBCResult, outputParam?: SQLResults) => void): false; queryResult(query: string | SQLQuery, params?: SQLParam[]): Promise<[result: null | ODBCResult, outparams: SQLResults]>; queryResultSync(query: string | SQLQuery, params?: SQLParam[]): ODBCResult | [ODBCResult | null, SQLResults]; querySync(query: string | SQLQuery, params?: SQLParam[]): SQLResults | undefined | null; executeFile(inputfile: string, delimiter: string, outputfile: string | undefined, cb: (err: SQLResults, res: string) => void): void; executeFile(inputfile: string, delimiter: string, cb: (err: SQLResults, res: string) => void): void; executeFile(inputfile: string | SQLExecuteFileParam, cb: (err: SQLResults, res: string) => void): void; executeFile(inputfile: string | SQLExecuteFileParam, delimiter?: string, outputfile?: string): Promise<string>; executeFileSync(inputfile: string | SQLExecuteFileParam, delimiter?: string, outputfile?: string | undefined): string; queryStream(sql: string | SQLQuery, params?: SQLParam[]): Readable; fetchStreamingResults(results: ODBCResult, stream: Readable): void; beginTransaction(cb: (err: DB2Error | null) => void): Database; beginTransaction(): Promise<true>; endTransaction(rollback: boolean, cb: (err: DB2Error | null) => void): Database; endTransaction(): Promise<true>; commitTransaction(cb: (err: DB2Error | null) => void): Database; commitTransaction(): Promise<void>; rollbackTransaction(cb: (err: DB2Error | null) => void): Database; rollbackTransaction(): Promise<void>; beginTransactionSync(): Database; endTransactionSync(rollback: boolean): Database; commitTransactionSync(): Database; rollbackTransactionSync(): Database; columns(catalog: string | null, schema: string | null, table: string | null, column: string | null, cb: (err: null | DB2Error, res: SQLResults | null, errInColumnsCall?: false) => void): void; columns(catalog: string | null, schema: string | null, table: string | null, column: string | null): Promise<SQLResults | null>; tables(catalog: string | null, schema: string | null, table: string | null, type: string | null, cb: (err: null | DB2Error, res: SQLResults | null, errInColumnsCall?: false) => void): void; tables(catalog: string | null, schema: string | null, table: string | null, type: string | null): Promise<SQLResults | null>; describe(obj: DescribeObject, cb: (err: null | DB2Error, res: SQLResults | null, errInColumnsCall?: false) => void): void; describe(obj: DescribeObject): Promise<SQLResults | null>; prepare(sql: string, cb: (err: DB2Error | null, stmt: ODBCStatement) => void): void; prepare(sql: string): Promise<ODBCStatement>; prepareSync(sql: string): ODBCStatement; setIsolationLevel(isolationLevel: 1 | 2 | 4 | 8 | 32): true; getInfoSync(infoType: number, infoLen: number): false | null | string | number; getInfo(infoType: number, infoLen: number, cb: (err: DB2Error | null, info: null | string | number) => void): void; getInfo(infoType: number, cb: (err: DB2Error | null, info: null | string | number) => void): void; getInfo(infoType: number, infoLen?: number): Promise<null | string | number>; getTypeInfoSync(dataType: number): SQLResults; getTypeInfo(dataType: number, cb: (err: DB2Error | null, info: false | SQLResults | null) => void): void; getTypeInfo(dataType: number): Promise<SQLResults>; getFunctionsSync(functionId: number): boolean; getFunctionsSync(functionId: 0): false | Record<string, boolean>; getFunctions(functionId: number, cb: (err: DB2Error | null, res: boolean) => void): void; getFunctions(functionId: 0, cb: (err: DB2Error | null, res: Record<string, boolean>) => void): void; setAttr(attr: number | string, value: number | null | string, cb: (err: DB2Error | null, res?: true) => void): void; setAttr(attr: number | string, value: number | null | string): Promise<true>; setAttrSync(attr: number, value: number | null | string): boolean; }