27 |
|
{ IBX For Lazarus (Firebird Express) } |
28 |
|
{ Contributor: Tony Whyman, MWA Software http://www.mwasoftware.co.uk } |
29 |
|
{ Portions created by MWA Software are copyright McCallum Whyman } |
30 |
< |
{ Associates Ltd 2011 } |
30 |
> |
{ Associates Ltd 2011 - 2018 } |
31 |
|
{ } |
32 |
|
{************************************************************************} |
33 |
|
|
43 |
|
{$ELSE} |
44 |
|
unix, |
45 |
|
{$ENDIF} |
46 |
< |
SysUtils, Classes, Db, |
47 |
< |
IBHeader, IB, IBCustomDataSet, IBSQL, IBSQLParser; |
46 |
> |
SysUtils, Classes, Db, IB, IBCustomDataSet, IBSQL; |
47 |
|
|
48 |
|
type |
49 |
|
|
55 |
|
FPrepared: Boolean; |
56 |
|
FParams: TParams; |
57 |
|
FText: string; |
59 |
– |
FRowsAffected: Integer; |
60 |
– |
FCheckRowsAffected: Boolean; |
58 |
|
FSQLUpdating: boolean; |
59 |
|
FInQueryChanged: boolean; |
60 |
|
function GetRowsAffected: Integer; |
68 |
|
procedure SetPrepared(Value: Boolean); |
69 |
|
procedure SetPrepare(Value: Boolean); |
70 |
|
procedure WriteParamData(Writer: TWriter); |
71 |
< |
function GetStmtHandle: TISC_STMT_HANDLE; |
71 |
> |
function GetStmtHandle: IStatement; |
72 |
|
procedure UpdateSQL; |
73 |
|
|
74 |
|
protected |
102 |
|
procedure ResetParser; override; |
103 |
|
property Prepared: Boolean read FPrepared write SetPrepare; |
104 |
|
property ParamCount: Word read GetParamsCount; |
105 |
< |
property StmtHandle: TISC_STMT_HANDLE read GetStmtHandle; |
105 |
> |
property StmtHandle: IStatement read GetStmtHandle; |
106 |
|
property StatementType; |
107 |
|
property Text: string read FText; |
108 |
|
property RowsAffected: Integer read GetRowsAffected; |
134 |
|
property TransactionFree; |
135 |
|
property OnFilterRecord; |
136 |
|
property OnValidatePost; |
137 |
+ |
property OnDeleteReturning; |
138 |
|
end; |
139 |
|
|
140 |
|
implementation |
141 |
|
|
142 |
+ |
uses FBMessages; |
143 |
+ |
|
144 |
|
{ TIBQuery } |
145 |
|
|
146 |
|
constructor TIBQuery.Create(AOwner: TComponent); |
150 |
|
TStringList(SQL).OnChange := QueryChanged; |
151 |
|
FParams := TParams.Create(Self); |
152 |
|
ParamCheck := True; |
153 |
– |
FRowsAffected := -1; |
153 |
|
end; |
154 |
|
|
155 |
|
destructor TIBQuery.Destroy; |
294 |
|
begin |
295 |
|
if Value then |
296 |
|
begin |
298 |
– |
FRowsAffected := -1; |
299 |
– |
FCheckRowsAffected := True; |
297 |
|
if Length(Text) > 1 then PrepareSQL |
298 |
|
else IBError(ibxeEmptySQLStatement, [nil]); |
299 |
|
end |
300 |
|
else |
301 |
|
begin |
305 |
– |
if FCheckRowsAffected then |
306 |
– |
FRowsAffected := RowsAffected; |
302 |
|
InternalUnPrepare; |
303 |
|
FParams.Clear; |
304 |
|
end; |
371 |
|
begin |
372 |
|
CheckInActive; |
373 |
|
if SQL.Count <= 0 then |
379 |
– |
begin |
380 |
– |
FCheckRowsAffected := False; |
374 |
|
IBError(ibxeEmptySQLStatement, [nil]); |
375 |
< |
end; |
375 |
> |
|
376 |
|
ActivateConnection(); |
377 |
|
DidActivate := ActivateTransaction; |
378 |
|
try |
383 |
|
finally |
384 |
|
if DidActivate then |
385 |
|
DeactivateTransaction; |
393 |
– |
FCheckRowsAffected := True; |
386 |
|
end; |
387 |
|
end; |
388 |
|
|
391 |
|
var |
392 |
|
i : integer; |
393 |
|
Buffer: Pointer; |
394 |
< |
SQLParam: TIBXSQLVAR; |
394 |
> |
SQLParam: ISQLParam; |
395 |
|
|
396 |
|
begin |
397 |
|
for I := 0 to FParams.Count - 1 do |
494 |
|
AddFieldToList(Params[i].Name, Self, DetailFields); |
495 |
|
end; |
496 |
|
|
497 |
< |
function TIBQuery.GetStmtHandle: TISC_STMT_HANDLE; |
497 |
> |
function TIBQuery.GetStmtHandle: IStatement; |
498 |
|
begin |
499 |
|
Result := SelectStmtHandle; |
500 |
|
end; |
501 |
|
|
502 |
|
procedure TIBQuery.UpdateSQL; |
503 |
|
begin |
504 |
< |
if not FSQLUpdating and not FInQueryChanged then |
504 |
> |
if not FSQLUpdating and not FInQueryChanged and (SQL.Text <> SelectSQL.Text) then |
505 |
|
begin |
506 |
|
FSQLUpdating := true; |
507 |
|
try |