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

Comparing ibx/trunk/runtime/nongui/IBQuery.pas (file contents):
Revision 269 by tony, Wed Mar 14 12:48:51 2018 UTC vs.
Revision 270 by tony, Fri Jan 18 11:10:37 2019 UTC

# Line 58 | Line 58 | type
58      FSQLUpdating: boolean;
59      FInQueryChanged: boolean;
60      function GetRowsAffected: Integer;
61 +    function ParseSQL(ParamList: TParams; SQL: string; DoClear: boolean): string;
62      procedure PrepareSQL;
63      procedure QueryChanged(Sender: TObject);
64      procedure ReadParamData(Reader: TReader);
# Line 114 | Line 115 | type
115      property AutoCommit;
116      property BufferChunks;
117      property CachedUpdates;
118 +    property CaseSensitiveParameterNames;
119      property DataSource read GetDataSource write SetDataSource;
120      property EnableStatistics;
121      property GenerateParamNames;
# Line 141 | Line 143 | end;
143  
144   implementation
145  
146 < uses FBMessages;
146 > uses FBMessages, IBUtils;
147  
148   { TIBQuery }
149  
# Line 233 | Line 235 | begin
235      begin
236        Disconnect;
237        if csDesigning in ComponentState then
238 <        FText := FParams.ParseSQL(SQL.Text, true)
238 >        FText := ParseSQL(FParams,SQL.Text, true)
239        else
240          FText := SQL.Text;
241        DataEvent(dePropertyChange, 0);
242      end else
243 <      FText := FParams.ParseSQL(SQL.Text, true);
243 >      FText := ParseSQL(FParams,SQL.Text, true);
244  
245      if not FSQLUpdating then
246      begin
# Line 351 | Line 353 | end;
353  
354  
355   function TIBQuery.ParamByName(const Value: string): TParam;
356 + var i: integer;
357   begin
358    if not Prepared then
359      Prepare;
360 <  Result := FParams.ParamByName(Value);
360 >  Result := nil;
361 >  if not CaseSensitiveParameterNames then
362 >    Result := FParams.ParamByName(Value)
363 >  else
364 >  begin
365 >    i := FParams.Count - 1;
366 >    while (Result = nil) and (i >= 0) do
367 >      if CompareStr(Value,FParams.Items[i].Name) = 0 then
368 >        Result := FParams.Items[i]
369 >      else
370 >        Dec(i);
371 >    if Result = nil then
372 >      IBError(ibxeParameterNameNotFound,[Value]);
373 >  end;
374   end;
375  
376   procedure TIBQuery.BatchInput(InputObject: TIBBatchInput);
# Line 453 | Line 469 | begin
469    begin
470      List := TParams.Create(Self);
471      try
472 <      FText := List.ParseSQL(SQL.Text, True);
472 >      FText := ParseSQL(List,SQL.Text, True);
473        List.AssignValues(FParams);
474        FParams.Clear;
475        FParams.Assign(List);
# Line 471 | Line 487 | begin
487     Result := QSelect.RowsAffected
488   end;
489  
490 + function TIBQuery.ParseSQL(ParamList: TParams; SQL: string; DoClear: boolean
491 +  ): string;
492 + var ParamNames: TStrings;
493 +    i: integer;
494 + begin
495 +  ParamNames := TStringList.Create;
496 +  try
497 +    Result := TSQLParamProcessor.Execute(SQL,GenerateParamNames,ParamNames);
498 +    if DoClear then ParamList.Clear;
499 +    for i := 0 to ParamNames.Count - 1 do
500 +    begin
501 +      if not CaseSensitiveParameterNames then
502 +        ParamNames[i] := AnsiUpperCase(ParamNames[i]);
503 +      if ParamList.FindParam(ParamNames[i]) = nil then
504 +        ParamList.CreateParam(ftUnknown, ParamNames[i], ptInput);
505 +    end;
506 +  finally
507 +    ParamNames.Free
508 +  end;
509 + end;
510 +
511  
512   procedure TIBQuery.GetDetailLinkFields(MasterFields, DetailFields: TList);
513  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines