24 |
|
{ Corporation. All Rights Reserved. } |
25 |
|
{ Contributor(s): Jeff Overcash } |
26 |
|
{ } |
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 } |
31 |
+ |
{ } |
32 |
|
{************************************************************************} |
33 |
|
|
34 |
|
unit IBQuery; |
38 |
|
{$Mode Delphi} |
39 |
|
|
40 |
|
uses |
41 |
< |
{$IFDEF LINUX } |
37 |
< |
unix, |
38 |
< |
{$ELSE} |
41 |
> |
{$IFDEF WINDOWS } |
42 |
|
Windows, |
43 |
+ |
{$ELSE} |
44 |
+ |
unix, |
45 |
|
{$ENDIF} |
46 |
|
SysUtils, Graphics, Classes, Controls, Db, |
47 |
|
IBHeader, IB, IBCustomDataSet, IBSQL; |
105 |
|
property Text: string read FText; |
106 |
|
property RowsAffected: Integer read GetRowsAffected; |
107 |
|
property GenerateParamNames: Boolean read FGenerateParamNames write FGenerateParamNames; |
108 |
+ |
// property Params: TParams read FParams write SetParamsList; |
109 |
|
|
110 |
|
published |
111 |
|
property Active; |
112 |
|
property BufferChunks; |
113 |
|
property CachedUpdates; |
114 |
|
property DataSource read GetDataSource write SetDataSource; |
115 |
< |
property Constraints stored ConstraintsStored; |
115 |
> |
// property Constraints stored ConstraintsStored; |
116 |
> |
property GeneratorField; |
117 |
|
property ParamCheck; |
118 |
|
property SQL: TStrings read FSQL write SetQuery; |
119 |
< |
property Params: TParams read FParams write SetParamsList stored False; |
119 |
> |
property Params: TParams read FParams write SetParamsList; |
120 |
|
property UniDirectional default False; |
121 |
|
property UpdateObject; |
122 |
|
property Filtered; |
231 |
|
FText := SQL.Text; |
232 |
|
DataEvent(dePropertyChange, 0); |
233 |
|
end else |
234 |
< |
FText := FParams.ParseSQL(SQL.Text, False); |
234 |
> |
FText := FParams.ParseSQL(SQL.Text, true); |
235 |
|
SelectSQL.Assign(SQL); |
236 |
|
end; |
237 |
|
|
249 |
|
|
250 |
|
function WriteData: Boolean; |
251 |
|
begin |
252 |
< |
if Filer.Ancestor <> nil then |
253 |
< |
Result := not FParams.IsEqual(TIBQuery(Filer.Ancestor).FParams) else |
252 |
> |
{The following results in a stream read error with nested frames. Hence commented out until |
253 |
> |
someone fixes the LCL } |
254 |
> |
{ if Filer.Ancestor <> nil then |
255 |
> |
Result := not FParams.IsEqual(TIBQuery(Filer.Ancestor).FParams) else} |
256 |
|
Result := FParams.Count > 0; |
257 |
|
end; |
258 |
|
|
263 |
|
|
264 |
|
procedure TIBQuery.ReadParamData(Reader: TReader); |
265 |
|
begin |
266 |
+ |
FParams.Clear; |
267 |
|
Reader.ReadValue; |
268 |
|
Reader.ReadCollection(FParams); |
269 |
|
end; |
299 |
|
var |
300 |
|
I: Integer; |
301 |
|
DataSet: TDataSet; |
302 |
+ |
Field: TField; |
303 |
|
|
304 |
|
procedure CheckRequiredParams; |
305 |
|
var |
319 |
|
begin |
320 |
|
DataSet.FieldDefs.Update; |
321 |
|
for I := 0 to FParams.Count - 1 do |
322 |
< |
with FParams[I] do |
323 |
< |
if not Bound then |
324 |
< |
begin |
325 |
< |
AssignField(DataSet.FieldByName(Name)); |
326 |
< |
Bound := False; |
327 |
< |
end; |
322 |
> |
if not FParams[I].Bound then |
323 |
> |
begin |
324 |
> |
Field := DataSet.FindField(FParams[I].Name); |
325 |
> |
if assigned(Field) then |
326 |
> |
begin |
327 |
> |
FParams[I].AssignField(Field); |
328 |
> |
FParams[I].Bound := False; |
329 |
> |
end; |
330 |
> |
end; |
331 |
|
end |
332 |
|
else |
333 |
|
CheckRequiredParams; |