* Only set cursor name for selectable queries

git-svn-id: trunk@47643 -
(cherry picked from commit a82ac3fb6a)
This commit is contained in:
michael 2020-11-30 17:13:07 +00:00 committed by marcoonthegit
parent c80ee7d794
commit 74cd768246

View File

@ -49,6 +49,7 @@ type
in_SQLDA : PXSQLDA;
ParamBinding : array of integer;
FieldBinding : array of integer;
CursorName : String;
end;
TIBTrans = Class(TSQLHandle)
@ -70,6 +71,7 @@ type
FBlobSegmentSize : word; //required for backward compatibilty; not used
FUseConnectionCharSetIfNone: Boolean;
FWireCompression : Boolean;
FCursorCount : Integer;
procedure ConnectFB;
procedure AllocSQLDA(var aSQLDA : PXSQLDA;Count : integer);
@ -773,6 +775,7 @@ begin
curs.sqlda := nil;
curs.StatementHandle := nil;
curs.FPrepared := False;
curs.CursorName:='';
AllocSQLDA(curs.SQLDA,0);
result := curs;
end;
@ -809,6 +812,7 @@ begin
begin
DatabaseHandle := GetHandle;
TransactionHandle := aTransaction.Handle;
CursorName:='';
if isc_dsql_allocate_statement(@Status[0], @DatabaseHandle, @StatementHandle) <> 0 then
CheckError('PrepareStatement', Status);
@ -908,6 +912,7 @@ begin
CheckError('FreeStatement', Status);
StatementHandle := nil;
FPrepared := False;
CursorName:='';
end;
FreeSQLDABuffer(SQLDA);
FreeSQLDABuffer(in_SQLDA);
@ -950,21 +955,29 @@ begin
FieldNameQuoteChars := NoQuotes
else
FieldNameQuoteChars := DoubleQuotes;
FCursorCount:=0;
end;
procedure TIBConnection.FreeFldBuffers(cursor : TSQLCursor);
begin
with cursor as TIBCursor do
begin
if isc_dsql_free_statement(@Status, @StatementHandle, DSQL_close)<>0 then
CheckError('Close Cursor', Status);
if FSelectable and (CursorName<>'') then
begin
if isc_dsql_free_statement(@Status, @StatementHandle, DSQL_close)<>0 then
CheckError('Close Cursor', Status); // Ignore this, it can already be closed.
end;
end;
end;
procedure TIBConnection.Execute(cursor: TSQLCursor;atransaction:tSQLtransaction; AParams : TParams);
var TransactionHandle : pointer;
out_SQLDA : PXSQLDA;
var
TransactionHandle : pointer;
out_SQLDA : PXSQLDA;
S: String;
begin
TransactionHandle := aTransaction.Handle;
if Assigned(APArams) and (AParams.count > 0) then SetParameters(cursor, atransaction, AParams);
@ -978,8 +991,17 @@ begin
out_SQLDA := nil;
if isc_dsql_execute2(@Status[0], @TransactionHandle, @StatementHandle, 1, in_SQLDA, out_SQLDA) <> 0 then
CheckError('Execute', Status);
if isc_dsql_set_cursor_name(@Status[0], @StatementHandle, 'sqldbcursor', 0) <> 0 then
CheckError('Open Cursor', Status);
if FSelectable then
begin
if CursorName='' then
begin
Inc(FCursorCount);
CursorName:='sqldbcursor'+IntToStr(FCursorCount);
end;
if isc_dsql_set_cursor_name(@Status[0], @StatementHandle, PChar(CursorName) , 0) <> 0 then
CheckError('Open Cursor', Status);
end
else
end;
end;