* Patch from Ladislav Karrach, in some cases SQLExecute returns SQL_NO_DATA when no error occured, bug #13654 + test

git-svn-id: trunk@13132 -
This commit is contained in:
joost 2009-05-10 20:30:01 +00:00
parent 6eeab240ba
commit 5ddddf60ae
2 changed files with 14 additions and 4 deletions

View File

@ -630,6 +630,7 @@ end;
procedure TODBCConnection.Execute(cursor: TSQLCursor; ATransaction: TSQLTransaction; AParams: TParams);
var
ODBCCursor:TODBCCursor;
Res:SQLRETURN;
begin
ODBCCursor:=cursor as TODBCCursor;
@ -638,12 +639,15 @@ begin
// execute the statement
case ODBCCursor.FSchemaType of
stNoSchema : ODBCCheckResult( SQLExecute(ODBCCursor.FSTMTHandle), SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not execute statement.' );
stTables : ODBCCheckResult( SQLTables (ODBCCursor.FSTMTHandle, nil, 0, nil, 0, nil, 0, nil, 0 ), SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not execute statement.' );
stColumns : ODBCCheckResult( SQLColumns(ODBCCursor.FSTMTHandle, nil, 0, nil, 0, @ODBCCursor.FQuery[1], length(ODBCCursor.FQuery), nil, 0 ), SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not execute statement.' );
stProcedures: ODBCCheckResult( SQLProcedures(ODBCCursor.FSTMTHandle, nil, 0, nil, 0, nil, 0 ), SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not execute statement.' );
stNoSchema : Res:=SQLExecute(ODBCCursor.FSTMTHandle); //SQL_NO_DATA returns searched update or delete statement that does not affect any rows
stTables : Res:=SQLTables (ODBCCursor.FSTMTHandle, nil, 0, nil, 0, nil, 0, nil, 0 );
stColumns : Res:=SQLColumns(ODBCCursor.FSTMTHandle, nil, 0, nil, 0, @ODBCCursor.FQuery[1], length(ODBCCursor.FQuery), nil, 0 );
stProcedures: Res:=SQLProcedures(ODBCCursor.FSTMTHandle, nil, 0, nil, 0, nil, 0 );
else Res:=SQL_NO_DATA;
end; {case}
if (Res<>SQL_NO_DATA) then ODBCCheckResult( Res, SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not execute statement.' );
// free parameter buffers
FreeParamBuffers(ODBCCursor);
end;

View File

@ -27,6 +27,7 @@ type
procedure TearDown; override;
procedure RunTest; override;
published
procedure TestEmptyUpdateQuery; // bug 13654
procedure TestClearUpdateableStatus;
procedure TestReadOnlyParseSQL; // bug 9254
procedure TestParseJoins; // bug 10148
@ -921,6 +922,11 @@ begin
inherited RunTest;
end;
procedure TTestFieldTypes.TestEmptyUpdateQuery;
begin
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('update fpdev set name=''nothing'' where (1=0)');
end;
procedure TTestFieldTypes.TestTableNames;
var TableList : TStringList;
i : integer;