35 |
|
|
36 |
|
{$Mode Delphi} |
37 |
|
|
38 |
+ |
{$IF FPC_FULLVERSION >= 20700 } |
39 |
+ |
{$codepage UTF8} |
40 |
+ |
{$ENDIF} |
41 |
+ |
|
42 |
|
{ IBSQL param names in dialect 3 quoted format (e.g. :"MyParam") are by default disabled. |
43 |
|
|
44 |
|
Dialect 3 quoted format parameter names represent a significant overhead and are of |
332 |
|
TIBSQL = class(TComponent) |
333 |
|
private |
334 |
|
FIBLoaded: Boolean; |
335 |
+ |
FOnSQLChanged: TNotifyEvent; |
336 |
|
FUniqueParamNames: Boolean; |
337 |
|
function GetFieldCount: integer; |
338 |
|
procedure SetUniqueParamNames(AValue: Boolean); |
371 |
|
procedure SetSQL(Value: TStrings); |
372 |
|
procedure SetTransaction(Value: TIBTransaction); |
373 |
|
procedure SQLChanging(Sender: TObject); |
374 |
+ |
procedure SQLChanged(Sender: TObject); |
375 |
|
procedure BeforeTransactionEnd(Sender: TObject; Action: TTransactionAction); |
376 |
|
public |
377 |
|
constructor Create(AOwner: TComponent); override; |
418 |
|
property SQL: TStrings read FSQL write SetSQL; |
419 |
|
property Transaction: TIBTransaction read GetTransaction write SetTransaction; |
420 |
|
property OnSQLChanging: TNotifyEvent read FOnSQLChanging write FOnSQLChanging; |
421 |
+ |
property OnSQLChanged: TNotifyEvent read FOnSQLChanged write FOnSQLChanged; |
422 |
|
end; |
423 |
|
|
424 |
|
implementation |
2144 |
|
|
2145 |
|
{ TIBSQL } |
2146 |
|
constructor TIBSQL.Create(AOwner: TComponent); |
2147 |
+ |
var GUID : TGUID; |
2148 |
|
begin |
2149 |
|
inherited Create(AOwner); |
2150 |
|
FIBLoaded := False; |
2161 |
|
FRecordCount := 0; |
2162 |
|
FSQL := TStringList.Create; |
2163 |
|
TStringList(FSQL).OnChanging := SQLChanging; |
2164 |
+ |
TStringList(FSQL).OnChange := SQLChanged; |
2165 |
|
FProcessedSQL := TStringList.Create; |
2166 |
|
FHandle := nil; |
2167 |
|
FSQLParams := TIBXSQLDA.Create(self,daInput); |
2168 |
|
FSQLRecord := TIBXSQLDA.Create(self,daOutput); |
2169 |
|
FSQLType := SQLUnknown; |
2170 |
|
FParamCheck := True; |
2171 |
< |
FCursor := HexStr(self); //Name + RandomString(8); |
2171 |
> |
CreateGuid(GUID); |
2172 |
> |
FCursor := GUIDToString(GUID); |
2173 |
|
if AOwner is TIBDatabase then |
2174 |
|
Database := TIBDatabase(AOwner) |
2175 |
|
else |
2321 |
|
FBOF := True; |
2322 |
|
FEOF := False; |
2323 |
|
FRecordCount := 0; |
2324 |
+ |
if not (csDesigning in ComponentState) then |
2325 |
+ |
MonitorHook.SQLExecute(Self); |
2326 |
|
if FGoToFirstRecordOnExecute then |
2327 |
|
Next; |
2328 |
|
end; |
2333 |
|
Database.SQLDialect, |
2334 |
|
FSQLParams.AsXSQLDA, |
2335 |
|
FSQLRecord.AsXSQLDA), True); |
2336 |
+ |
if not (csDesigning in ComponentState) then |
2337 |
+ |
MonitorHook.SQLExecute(Self); |
2338 |
|
(* if (fetch_res <> 0) and (fetch_res <> isc_deadlock) then |
2339 |
|
begin |
2340 |
|
{ Sometimes a prepared stored procedure appears to get |
2358 |
|
@FHandle, |
2359 |
|
Database.SQLDialect, |
2360 |
|
FSQLParams.AsXSQLDA), True); |
2361 |
+ |
if not (csDesigning in ComponentState) then |
2362 |
+ |
MonitorHook.SQLExecute(Self); |
2363 |
|
end; |
2348 |
– |
if not (csDesigning in ComponentState) then |
2349 |
– |
MonitorHook.SQLExecute(Self); |
2364 |
|
FBase.DoAfterExecQuery(self); |
2365 |
|
// writeln('Rows Affected = ',RowsAffected); |
2366 |
|
end; |
2826 |
|
if FHandle <> nil then FreeHandle; |
2827 |
|
end; |
2828 |
|
|
2829 |
+ |
procedure TIBSQL.SQLChanged(Sender: TObject); |
2830 |
+ |
begin |
2831 |
+ |
if assigned(OnSQLChanged) then |
2832 |
+ |
OnSQLChanged(self); |
2833 |
+ |
end; |
2834 |
+ |
|
2835 |
|
procedure TIBSQL.BeforeTransactionEnd(Sender: TObject; |
2836 |
|
Action: TTransactionAction); |
2837 |
|
begin |