--- ibx/trunk/runtime/IBQuery.pas 2011/02/18 16:26:16 5 +++ ibx/trunk/runtime/IBQuery.pas 2012/08/05 18:28:19 7 @@ -24,6 +24,11 @@ { Corporation. All Rights Reserved. } { Contributor(s): Jeff Overcash } { } +{ IBX For Lazarus (Firebird Express) } +{ Contributor: Tony Whyman, MWA Software http://www.mwasoftware.co.uk } +{ Portions created by MWA Software are copyright McCallum Whyman } +{ Associates Ltd 2011 } +{ } {************************************************************************} unit IBQuery; @@ -33,10 +38,10 @@ interface {$Mode Delphi} uses -{$IFDEF LINUX } - unix, -{$ELSE} +{$IFDEF WINDOWS } Windows, +{$ELSE} + unix, {$ENDIF} SysUtils, Graphics, Classes, Controls, Db, IBHeader, IB, IBCustomDataSet, IBSQL; @@ -100,16 +105,18 @@ type property Text: string read FText; property RowsAffected: Integer read GetRowsAffected; property GenerateParamNames: Boolean read FGenerateParamNames write FGenerateParamNames; + // property Params: TParams read FParams write SetParamsList; published property Active; property BufferChunks; property CachedUpdates; property DataSource read GetDataSource write SetDataSource; - property Constraints stored ConstraintsStored; + // property Constraints stored ConstraintsStored; + property GeneratorField; property ParamCheck; property SQL: TStrings read FSQL write SetQuery; - property Params: TParams read FParams write SetParamsList stored False; + property Params: TParams read FParams write SetParamsList; property UniDirectional default False; property UpdateObject; property Filtered; @@ -224,7 +231,7 @@ begin FText := SQL.Text; DataEvent(dePropertyChange, 0); end else - FText := FParams.ParseSQL(SQL.Text, False); + FText := FParams.ParseSQL(SQL.Text, true); SelectSQL.Assign(SQL); end; @@ -242,8 +249,10 @@ procedure TIBQuery.DefineProperties(File function WriteData: Boolean; begin - if Filer.Ancestor <> nil then - Result := not FParams.IsEqual(TIBQuery(Filer.Ancestor).FParams) else + {The following results in a stream read error with nested frames. Hence commented out until + someone fixes the LCL } +{ if Filer.Ancestor <> nil then + Result := not FParams.IsEqual(TIBQuery(Filer.Ancestor).FParams) else} Result := FParams.Count > 0; end; @@ -254,6 +263,7 @@ end; procedure TIBQuery.ReadParamData(Reader: TReader); begin + FParams.Clear; Reader.ReadValue; Reader.ReadCollection(FParams); end; @@ -289,6 +299,7 @@ procedure TIBQuery.SetParamsFromCursor; var I: Integer; DataSet: TDataSet; + Field: TField; procedure CheckRequiredParams; var @@ -308,12 +319,15 @@ begin begin DataSet.FieldDefs.Update; for I := 0 to FParams.Count - 1 do - with FParams[I] do - if not Bound then - begin - AssignField(DataSet.FieldByName(Name)); - Bound := False; - end; + if not FParams[I].Bound then + begin + Field := DataSet.FindField(FParams[I].Name); + if assigned(Field) then + begin + FParams[I].AssignField(Field); + FParams[I].Bound := False; + end; + end; end else CheckRequiredParams;