mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 14:27:59 +02:00
fcl-db: odbc: go to first selectable result. issue #38664
git-svn-id: trunk@49049 -
(cherry picked from commit fa0b053b21
)
This commit is contained in:
parent
2338aa4d5e
commit
35da09230a
@ -873,10 +873,15 @@ begin
|
||||
|
||||
if (Res<>SQL_NO_DATA) then ODBCCheckResult( Res, SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not execute statement.' );
|
||||
|
||||
if ODBCSuccess(SQLNumResultCols(ODBCCursor.FSTMTHandle, ColumnCount)) then
|
||||
ODBCCursor.FSelectable:=ColumnCount>0
|
||||
else
|
||||
ODBCCursor.FSelectable:=False;
|
||||
// go to first selectable result - see issue #38664
|
||||
ODBCCursor.FSelectable:=False;
|
||||
while not ODBCCursor.FSelectable and ODBCSuccess(Res) and
|
||||
ODBCSuccess(SQLNumResultCols(ODBCCursor.FSTMTHandle, ColumnCount)) do
|
||||
begin
|
||||
ODBCCursor.FSelectable:=ColumnCount>0;
|
||||
if not ODBCCursor.FSelectable then
|
||||
Res:=SQLMoreResults(ODBCCursor.FSTMTHandle);
|
||||
end;
|
||||
|
||||
finally
|
||||
// free parameter buffers
|
||||
|
@ -1217,6 +1217,7 @@ type TSQLFetch=function (StatementHandle:SQLHSTMT):SQLRETURN;{$ifdef fpc} extd
|
||||
|
||||
type TSQLNumResultCols=function (StatementHandle:SQLHSTMT;
|
||||
var ColumnCount:SQLSMALLINT):SQLRETURN;{$ifdef fpc} extdecl {$else} stdcall {$endif};
|
||||
type TSQLMoreResults=function (StatementHandle:SQLHSTMT):SQLRETURN;{$ifdef fpc} extdecl {$else} stdcall {$endif};
|
||||
|
||||
type TSQLDescribeCol=function (StatementHandle:SQLHSTMT;
|
||||
ColumnNumber:SQLUSMALLINT;ColumnName:PSQLCHAR;
|
||||
@ -1444,6 +1445,7 @@ var SQLCloseCursor:TSQLCloseCursor;
|
||||
var SQLExecute:TSQLExecute;
|
||||
var SQLFetch:TSQLFetch;
|
||||
var SQLNumResultCols:TSQLNumResultCols;
|
||||
var SQLMoreResults:TSQLMoreResults;
|
||||
var SQLDescribeColA:TSQLDescribeCol;
|
||||
SQLDescribeColW:TSQLDescribeColW;
|
||||
var SQLFetchScroll:TSQLFetchScroll;
|
||||
@ -1608,6 +1610,8 @@ var
|
||||
function SQLNumResultCols(
|
||||
StatementHandle:SQLHSTMT;
|
||||
var ColumnCount:SQLSMALLINT):SQLRETURN;{$ifdef fpc} extdecl {$else} stdcall {$endif};external odbclib;
|
||||
function SQLMoreResults(
|
||||
StatementHandle:SQLHSTMT):SQLRETURN;{$ifdef fpc} extdecl {$else} stdcall {$endif};external odbclib;
|
||||
function SQLDescribeCol(
|
||||
StatementHandle:SQLHSTMT;
|
||||
ColumnNumber:SQLUSMALLINT;
|
||||
@ -1918,6 +1922,7 @@ begin
|
||||
pointer(SQLExecute) := GetProcedureAddress(ODBCLibraryHandle,'SQLExecute');
|
||||
pointer(SQLFetch) := GetProcedureAddress(ODBCLibraryHandle,'SQLFetch');
|
||||
pointer(SQLNumResultCols) := GetProcedureAddress(ODBCLibraryHandle,'SQLNumResultCols');
|
||||
pointer(SQLMoreResults) := GetProcedureAddress(ODBCLibraryHandle,'SQLMoreResults');
|
||||
pointer(SQLFetchScroll) := GetProcedureAddress(ODBCLibraryHandle,'SQLFetchScroll');
|
||||
pointer(SQLExtendedFetch) := GetProcedureAddress(ODBCLibraryHandle,'SQLExtendedFetch');
|
||||
pointer(SQLGetData) := GetProcedureAddress(ODBCLibraryHandle,'SQLGetData');
|
||||
|
Loading…
Reference in New Issue
Block a user