ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/runtime/IBQuery.pas
(Generate patch)

Comparing ibx/trunk/runtime/IBQuery.pas (file contents):
Revision 19 by tony, Mon Jul 7 13:00:15 2014 UTC vs.
Revision 21 by tony, Thu Feb 26 10:33:34 2015 UTC

# Line 44 | Line 44 | uses
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;
# Line 58 | Line 58 | type
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);
# Line 79 | Line 80 | type
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;
# Line 104 | Line 106 | type
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;
# Line 214 | Line 217 | begin
217    if not (csReading in ComponentState) then
218    begin
219      Disconnect;
220 +    if HasParser and not FSQLUpdating then
221 +    begin
222 +      FSQLUpdating := true;
223 +      try
224 +        SQL.Text := Parser.SQLText;
225 +      finally
226 +        FSQLUpdating := false
227 +      end;
228 +    end;
229      if ParamCheck or (csDesigning in ComponentState) then
230      begin
231        List := TParams.Create(Self);
# Line 259 | Line 271 | begin
271    Filer.DefineProperty('ParamData', ReadParamData, WriteParamData, WriteData); {do not localize}
272   end;
273  
274 +
275   procedure TIBQuery.ReadParamData(Reader: TReader);
276   begin
277    FParams.Clear;
# Line 379 | Line 392 | procedure TIBQuery.SetParams;
392   var
393   i : integer;
394   Buffer: Pointer;
395 + SQLParam: TIBXSQLVAR;
396  
397   begin
398    for I := 0 to FParams.Count - 1 do
399    begin
400 +    SQLParam :=  SQLParams.ByName(Params[i].Name);
401      if Params[i].IsNull then
402 <      SQLParams[i].IsNull := True
402 >      SQLParam.IsNull := True
403      else begin
404 <      SQLParams[i].IsNull := False;
404 >      SQLParam.IsNull := False;
405        case Params[i].DataType of
406          ftBytes:
407          begin
408            GetMem(Buffer,Params[i].GetDataSize);
409            try
410              Params[i].GetData(Buffer);
411 <            SQLParams[i].AsPointer := Buffer;
411 >            SQLParam.AsPointer := Buffer;
412            finally
413              FreeMem(Buffer);
414            end;
415          end;
416          ftString:
417 <          SQLParams[i].AsString := Params[i].AsString;
417 >          SQLParam.AsString := Params[i].AsString;
418          ftBoolean, ftSmallint, ftWord:
419 <          SQLParams[i].AsShort := Params[i].AsSmallInt;
419 >          SQLParam.AsShort := Params[i].AsSmallInt;
420          ftInteger:
421 <          SQLParams[i].AsLong := Params[i].AsInteger;
421 >          SQLParam.AsLong := Params[i].AsInteger;
422          ftLargeInt:
423 <          SQLParams[i].AsInt64 := Params[i].AsLargeInt;
423 >          SQLParam.AsInt64 := Params[i].AsLargeInt;
424          ftFloat:
425 <         SQLParams[i].AsDouble := Params[i].AsFloat;
425 >         SQLParam.AsDouble := Params[i].AsFloat;
426          ftBCD, ftCurrency:
427 <          SQLParams[i].AsCurrency := Params[i].AsCurrency;
427 >          SQLParam.AsCurrency := Params[i].AsCurrency;
428          ftDate:
429 <          SQLParams[i].AsDate := Params[i].AsDateTime;
429 >          SQLParam.AsDate := Params[i].AsDateTime;
430          ftTime:
431 <          SQLParams[i].AsTime := Params[i].AsDateTime;
431 >          SQLParam.AsTime := Params[i].AsDateTime;
432          ftDateTime:
433 <          SQLParams[i].AsDateTime := Params[i].AsDateTime;
433 >          SQLParam.AsDateTime := Params[i].AsDateTime;
434          ftBlob, ftMemo:
435 <          SQLParams[i].AsString := Params[i].AsString;
435 >          SQLParam.AsString := Params[i].AsString;
436          else
437            IBError(ibxeNotSupported, [nil]);
438        end;
# Line 469 | Line 484 | begin
484    Result := SelectStmtHandle;
485   end;
486  
487 + function TIBQuery.CreateParser: TSelectSQLParser;
488 + begin
489 +  Result := inherited CreateParser;
490 +  Result.OnSQLChanging := QueryChanged;
491 + end;
492 +
493   function TIBQuery.GenerateQueryForLiveUpdate : Boolean;
494   begin
495    Result := False;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines