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; |
35 |
|
|
36 |
|
interface |
37 |
|
|
38 |
< |
uses Windows, SysUtils, Graphics, Classes, Controls, Db, StdVCL, |
38 |
> |
{$Mode Delphi} |
39 |
> |
|
40 |
> |
uses |
41 |
> |
{$IFDEF WINDOWS } |
42 |
> |
Windows, |
43 |
> |
{$ELSE} |
44 |
> |
unix, |
45 |
> |
{$ENDIF} |
46 |
> |
SysUtils, Graphics, Classes, Controls, Db, |
47 |
|
IBHeader, IB, IBCustomDataSet, IBSQL; |
48 |
|
|
49 |
|
type |
74 |
|
|
75 |
|
protected |
76 |
|
{ IProviderSupport } |
77 |
< |
procedure PSExecute; override; |
77 |
> |
(* procedure PSExecute; override; |
78 |
|
function PSGetParams: TParams; override; |
79 |
|
function PSGetTableName: string; override; |
80 |
|
procedure PSSetCommandText(const CommandText: string); override; |
81 |
< |
procedure PSSetParams(AParams: TParams); override; |
81 |
> |
procedure PSSetParams(AParams: TParams); override; *) |
82 |
|
|
83 |
|
procedure DefineProperties(Filer: TFiler); override; |
84 |
|
procedure InitFieldDefs; override; |
94 |
|
procedure BatchInput(InputObject: TIBBatchInput); |
95 |
|
procedure BatchOutput(OutputObject: TIBBatchOutput); |
96 |
|
procedure ExecSQL; |
97 |
< |
procedure GetDetailLinkFields(MasterFields, DetailFields: TList); override; |
97 |
> |
procedure GetDetailLinkFields(MasterFields, DetailFields: TList);(* override;*) |
98 |
|
function ParamByName(const Value: string): TParam; |
99 |
|
procedure Prepare; |
100 |
|
procedure UnPrepare; |
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; |
156 |
|
|
157 |
|
procedure TIBQuery.InitFieldDefs; |
158 |
|
begin |
159 |
< |
inherited; |
159 |
> |
inherited InitFieldDefs; |
160 |
|
end; |
161 |
|
|
162 |
|
procedure TIBQuery.InternalOpen; |
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; |
492 |
|
end; |
493 |
|
|
494 |
|
{ TIBQuery IProviderSupport } |
495 |
< |
|
495 |
> |
(* |
496 |
|
function TIBQuery.PSGetParams: TParams; |
497 |
|
begin |
498 |
|
Result := Params; |
520 |
|
if CommandText <> '' then |
521 |
|
SQL.Text := CommandText; |
522 |
|
end; |
523 |
< |
|
523 |
> |
*) |
524 |
|
end. |
525 |
|
|