44 |
|
unix, |
45 |
|
{$ENDIF} |
46 |
|
SysUtils, Graphics, Classes, Controls, Db, |
47 |
< |
IBHeader, IB, IBCustomDataSet, IBSQL; |
47 |
> |
IBHeader, IB, IBCustomDataSet, IBSQL, IBSQLParser; |
48 |
|
|
49 |
|
type |
50 |
|
|
51 |
|
{ TIBQuery } |
52 |
|
|
53 |
< |
TIBQuery = class(TIBCustomDataSet) |
53 |
> |
TIBQuery = class(TIBParserDataSet) |
54 |
|
private |
55 |
|
FSQL: TStrings; |
56 |
|
FPrepared: Boolean; |
58 |
|
FText: string; |
59 |
|
FRowsAffected: Integer; |
60 |
|
FCheckRowsAffected: Boolean; |
61 |
+ |
FSQLUpdating: boolean; |
62 |
|
function GetRowsAffected: Integer; |
63 |
|
procedure PrepareSQL(Value: PChar); |
64 |
|
procedure QueryChanged(Sender: TObject); |
80 |
|
procedure PSSetCommandText(const CommandText: string); override; |
81 |
|
procedure PSSetParams(AParams: TParams); override; *) |
82 |
|
|
83 |
+ |
function CreateParser: TSelectSQLParser; override; |
84 |
|
procedure DefineProperties(Filer: TFiler); override; |
85 |
|
procedure InitFieldDefs; override; |
86 |
|
procedure InternalOpen; override; |
106 |
|
property Text: string read FText; |
107 |
|
property RowsAffected: Integer read GetRowsAffected; |
108 |
|
// property Params: TParams read FParams write SetParamsList; |
109 |
+ |
property BaseSQLSelect; |
110 |
|
|
111 |
|
published |
112 |
|
property Active; |
113 |
+ |
property AutoCommit; |
114 |
|
property BufferChunks; |
115 |
|
property CachedUpdates; |
116 |
|
property DataSource read GetDataSource write SetDataSource; |
218 |
|
if not (csReading in ComponentState) then |
219 |
|
begin |
220 |
|
Disconnect; |
221 |
+ |
if HasParser and not FSQLUpdating then |
222 |
+ |
begin |
223 |
+ |
FSQLUpdating := true; |
224 |
+ |
try |
225 |
+ |
SQL.Text := Parser.SQLText; |
226 |
+ |
finally |
227 |
+ |
FSQLUpdating := false |
228 |
+ |
end; |
229 |
+ |
end; |
230 |
|
if ParamCheck or (csDesigning in ComponentState) then |
231 |
|
begin |
232 |
|
List := TParams.Create(Self); |
272 |
|
Filer.DefineProperty('ParamData', ReadParamData, WriteParamData, WriteData); {do not localize} |
273 |
|
end; |
274 |
|
|
275 |
+ |
|
276 |
|
procedure TIBQuery.ReadParamData(Reader: TReader); |
277 |
|
begin |
278 |
|
FParams.Clear; |
393 |
|
var |
394 |
|
i : integer; |
395 |
|
Buffer: Pointer; |
396 |
+ |
SQLParam: TIBXSQLVAR; |
397 |
|
|
398 |
|
begin |
399 |
|
for I := 0 to FParams.Count - 1 do |
400 |
|
begin |
401 |
+ |
SQLParam := SQLParams.ByName(Params[i].Name); |
402 |
|
if Params[i].IsNull then |
403 |
< |
SQLParams[i].IsNull := True |
403 |
> |
SQLParam.IsNull := True |
404 |
|
else begin |
405 |
< |
SQLParams[i].IsNull := False; |
405 |
> |
SQLParam.IsNull := False; |
406 |
|
case Params[i].DataType of |
407 |
|
ftBytes: |
408 |
|
begin |
409 |
|
GetMem(Buffer,Params[i].GetDataSize); |
410 |
|
try |
411 |
|
Params[i].GetData(Buffer); |
412 |
< |
SQLParams[i].AsPointer := Buffer; |
412 |
> |
SQLParam.AsPointer := Buffer; |
413 |
|
finally |
414 |
|
FreeMem(Buffer); |
415 |
|
end; |
416 |
|
end; |
417 |
|
ftString: |
418 |
< |
SQLParams[i].AsString := Params[i].AsString; |
419 |
< |
ftBoolean, ftSmallint, ftWord: |
420 |
< |
SQLParams[i].AsShort := Params[i].AsSmallInt; |
418 |
> |
SQLParam.AsString := Params[i].AsString; |
419 |
> |
ftBoolean: |
420 |
> |
SQLParam.AsBoolean := Params[i].AsBoolean; |
421 |
> |
ftSmallint, ftWord: |
422 |
> |
SQLParam.AsShort := Params[i].AsSmallInt; |
423 |
|
ftInteger: |
424 |
< |
SQLParams[i].AsLong := Params[i].AsInteger; |
424 |
> |
SQLParam.AsLong := Params[i].AsInteger; |
425 |
|
ftLargeInt: |
426 |
< |
SQLParams[i].AsInt64 := Params[i].AsLargeInt; |
426 |
> |
SQLParam.AsInt64 := Params[i].AsLargeInt; |
427 |
|
ftFloat: |
428 |
< |
SQLParams[i].AsDouble := Params[i].AsFloat; |
428 |
> |
SQLParam.AsDouble := Params[i].AsFloat; |
429 |
|
ftBCD, ftCurrency: |
430 |
< |
SQLParams[i].AsCurrency := Params[i].AsCurrency; |
430 |
> |
SQLParam.AsCurrency := Params[i].AsCurrency; |
431 |
|
ftDate: |
432 |
< |
SQLParams[i].AsDate := Params[i].AsDateTime; |
432 |
> |
SQLParam.AsDate := Params[i].AsDateTime; |
433 |
|
ftTime: |
434 |
< |
SQLParams[i].AsTime := Params[i].AsDateTime; |
434 |
> |
SQLParam.AsTime := Params[i].AsDateTime; |
435 |
|
ftDateTime: |
436 |
< |
SQLParams[i].AsDateTime := Params[i].AsDateTime; |
436 |
> |
SQLParam.AsDateTime := Params[i].AsDateTime; |
437 |
|
ftBlob, ftMemo: |
438 |
< |
SQLParams[i].AsString := Params[i].AsString; |
438 |
> |
SQLParam.AsString := Params[i].AsString; |
439 |
|
else |
440 |
|
IBError(ibxeNotSupported, [nil]); |
441 |
|
end; |
487 |
|
Result := SelectStmtHandle; |
488 |
|
end; |
489 |
|
|
490 |
+ |
function TIBQuery.CreateParser: TSelectSQLParser; |
491 |
+ |
begin |
492 |
+ |
Result := inherited CreateParser; |
493 |
+ |
Result.OnSQLChanging := QueryChanged; |
494 |
+ |
end; |
495 |
+ |
|
496 |
|
function TIBQuery.GenerateQueryForLiveUpdate : Boolean; |
497 |
|
begin |
498 |
|
Result := False; |
544 |
|
end; |
545 |
|
*) |
546 |
|
end. |
547 |
< |
|
547 |
> |
|