mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-08 14:03:23 +00:00
* fix #9771
* map SQLLEN SQLULEN
* fix proc params take TSqlLen
Co-authored-by: bung87 <crc32@qq.com>
(cherry picked from commit ce0552c100)
This commit is contained in:
@@ -242,7 +242,7 @@ proc tryExec*(db: var DbConn, query: SqlQuery, args: varargs[string, `$`]): bool
|
||||
try:
|
||||
db.prepareFetchDirect(query, args)
|
||||
var
|
||||
rCnt = -1
|
||||
rCnt:TSqlLen = -1
|
||||
res = SQLRowCount(db.stmt, rCnt)
|
||||
properFreeResult(SQL_HANDLE_STMT, db.stmt)
|
||||
if res != SQL_SUCCESS: dbError(db)
|
||||
@@ -461,10 +461,10 @@ proc execAffectedRows*(db: var DbConn, query: SqlQuery,
|
||||
var q = dbFormat(query, args)
|
||||
db.sqlCheck(SQLPrepare(db.stmt, q.PSQLCHAR, q.len.TSqlSmallInt))
|
||||
rawExec(db, query, args)
|
||||
var rCnt = -1
|
||||
var rCnt:TSqlLen = -1
|
||||
db.sqlCheck(SQLRowCount(db.hDb, rCnt))
|
||||
properFreeResult(SQL_HANDLE_STMT, db.stmt)
|
||||
result = rCnt
|
||||
result = rCnt.int64
|
||||
|
||||
proc close*(db: var DbConn) {.
|
||||
tags: [WriteDbEffect], raises: [].} =
|
||||
@@ -489,7 +489,7 @@ proc open*(connection, user, password, database: string): DbConn {.
|
||||
## Currently the database parameter is ignored,
|
||||
## but included to match ``open()`` in the other db_xxxxx library modules.
|
||||
var
|
||||
val: TSqlInteger = SQL_OV_ODBC3
|
||||
val = SQL_OV_ODBC3
|
||||
resLen = 0
|
||||
result = (hDb: nil, env: nil, stmt: nil)
|
||||
# allocate environment handle
|
||||
@@ -497,7 +497,7 @@ proc open*(connection, user, password, database: string): DbConn {.
|
||||
if res != SQL_SUCCESS: dbError("Error: unable to initialise ODBC environment.")
|
||||
res = SQLSetEnvAttr(result.env,
|
||||
SQL_ATTR_ODBC_VERSION.TSqlInteger,
|
||||
val, resLen.TSqlInteger)
|
||||
cast[SqlPointer](val.addr), resLen.TSqlInteger)
|
||||
if res != SQL_SUCCESS: dbError("Error: unable to set ODBC driver version.")
|
||||
# allocate hDb handle
|
||||
res = SQLAllocHandle(SQL_HANDLE_DBC, result.env, result.hDb)
|
||||
|
||||
@@ -47,8 +47,10 @@ type
|
||||
SqlHDBC* = SqlHandle
|
||||
SqlHStmt* = SqlHandle
|
||||
SqlHDesc* = SqlHandle
|
||||
TSqlInteger* = int
|
||||
SqlUInteger* = int
|
||||
TSqlInteger* = int32
|
||||
SqlUInteger* = int32
|
||||
TSqlLen* = int64
|
||||
TSqlULen* = uint64
|
||||
SqlPointer* = pointer
|
||||
TSqlReal* = cfloat
|
||||
TSqlDouble* = cdouble
|
||||
@@ -668,7 +670,7 @@ proc SQLAllocHandle*(HandleType: TSqlSmallInt, InputHandle: SqlHandle,
|
||||
OutputHandlePtr: var SqlHandle): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLSetEnvAttr*(EnvironmentHandle: SqlHEnv, Attribute: TSqlInteger,
|
||||
Value: TSqlInteger, StringLength: TSqlInteger): TSqlSmallInt{.
|
||||
Value: SqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLGetEnvAttr*(EnvironmentHandle: SqlHEnv, Attribute: TSqlInteger,
|
||||
Value: SqlPointer, BufferLength: TSqlInteger,
|
||||
@@ -718,14 +720,14 @@ proc SQLNumResultCols*(StatementHandle: SqlHStmt, ColumnCount: var TSqlSmallInt)
|
||||
proc SQLDescribeCol*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
|
||||
ColumnName: PSQLCHAR, BufferLength: TSqlSmallInt,
|
||||
NameLength: var TSqlSmallInt, DataType: var TSqlSmallInt,
|
||||
ColumnSize: var SqlUInteger,
|
||||
ColumnSize: var TSQLULEN,
|
||||
DecimalDigits: var TSqlSmallInt, Nullable: var TSqlSmallInt): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLFetchScroll*(StatementHandle: SqlHStmt, FetchOrientation: TSqlSmallInt,
|
||||
FetchOffset: TSqlInteger): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLExtendedFetch*(hstmt: SqlHStmt, fFetchType: SqlUSmallInt,
|
||||
irow: TSqlInteger, pcrow: PSQLUINTEGER,
|
||||
irow: TSqlInteger, pcrow: var TSQLULEN,
|
||||
rgfRowStatus: PSQLUSMALLINT): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLGetData*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
|
||||
@@ -743,13 +745,13 @@ proc SQLGetInfo*(ConnectionHandle: SqlHDBC, InfoType: SqlUSmallInt,
|
||||
InfoValue: SqlPointer, BufferLength: TSqlSmallInt,
|
||||
StringLength: PSQLSMALLINT): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLBulkOperations*(StatementHandle: SqlHStmt, Operation: TSqlSmallInt): TSqlSmallInt{.
|
||||
proc SQLBulkOperations*(StatementHandle: SqlHStmt, Operation: SqlUSmallInt): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLPutData*(StatementHandle: SqlHStmt, Data: SqlPointer,
|
||||
StrLen_or_Ind: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
StrLen_or_Ind: TSQLLEN): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLBindCol*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
|
||||
TargetType: TSqlSmallInt, TargetValue: SqlPointer,
|
||||
BufferLength: TSqlInteger, StrLen_or_Ind: PSQLINTEGER): TSqlSmallInt{.
|
||||
BufferLength: TSqlLEN, StrLen_or_Ind: PSQLINTEGER): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLSetPos*(hstmt: SqlHStmt, irow: SqlUSmallInt, fOption: SqlUSmallInt,
|
||||
fLock: SqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
@@ -772,13 +774,13 @@ proc SQLGetCursorName*(StatementHandle: SqlHStmt, CursorName: PSQLCHAR,
|
||||
proc SQLSetCursorName*(StatementHandle: SqlHStmt, CursorName: PSQLCHAR,
|
||||
NameLength: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLRowCount*(StatementHandle: SqlHStmt, RowCount: var TSqlInteger): TSqlSmallInt{.
|
||||
proc SQLRowCount*(StatementHandle: SqlHStmt, RowCount: var TSQLLEN): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLBindParameter*(hstmt: SqlHStmt, ipar: SqlUSmallInt,
|
||||
fParamType: TSqlSmallInt, fCType: TSqlSmallInt,
|
||||
fSqlType: TSqlSmallInt, cbColDef: SqlUInteger,
|
||||
fSqlType: TSqlSmallInt, cbColDef: TSQLULEN,
|
||||
ibScale: TSqlSmallInt, rgbValue: SqlPointer,
|
||||
cbValueMax: TSqlInteger, pcbValue: PSQLINTEGER): TSqlSmallInt{.
|
||||
cbValueMax: TSQLLEN, pcbValue: var TSQLLEN): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLFreeStmt*(StatementHandle: SqlHStmt, Option: SqlUSmallInt): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
@@ -786,7 +788,7 @@ proc SQLColAttribute*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
|
||||
FieldIdentifier: SqlUSmallInt,
|
||||
CharacterAttribute: PSQLCHAR, BufferLength: TSqlSmallInt,
|
||||
StringLength: PSQLSMALLINT,
|
||||
NumericAttribute: SqlPointer): TSqlSmallInt{.
|
||||
NumericAttribute: TSQLLEN): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLEndTran*(HandleType: TSqlSmallInt, Handle: SqlHandle,
|
||||
CompletionType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
|
||||
|
||||
Reference in New Issue
Block a user