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

Comparing ibx/trunk/runtime/IBStoredProc.pas (file contents):
Revision 17 by tony, Sat Dec 28 19:22:24 2013 UTC vs.
Revision 23 by tony, Fri Mar 13 10:26:52 2015 UTC

# Line 67 | Line 67 | type
67  
68      procedure DefineProperties(Filer: TFiler); override;
69      procedure SetFiltered(Value: Boolean); override;
70 +    procedure InitFieldDefs; override;
71      function GetParamsCount: Word;
72      procedure SetPrepared(Value: Boolean);
73      procedure SetPrepare(Value: Boolean);
# Line 199 | Line 200 | begin
200      inherited SetFiltered(value);
201   end;
202  
203 + procedure TIBStoredProc.InitFieldDefs;
204 + begin
205 +  if SelectSQL.Text = '' then
206 +     GenerateSQL;
207 +  inherited InitFieldDefs;
208 + end;
209 +
210   procedure TIBStoredProc.GenerateSQL;
211 +
212 + var Params: TStringList;
213 +
214 +  function FormatParameter(Dialect: Integer; Value: String): String;
215 +  var j: integer;
216 +  begin
217 +    Value := Trim(Value);
218 +    if Dialect = 1 then
219 +       Result := AnsiUpperCase(Value)
220 +    else
221 +    begin
222 +      j := 1;
223 +      Value := Space2Underscore(AnsiUpperCase(Value));
224 +      Result := Value;
225 +      while Params.IndexOf(Result) <> -1 do
226 +      begin
227 +        Result := Value + IntToStr(j);
228 +        Inc(j)
229 +      end;
230 +      Params.Add(Result)
231 +    end;
232 +  end;
233 +
234   var
235    Query : TIBSQL;
236    input : string;
237   begin
238 +  input := '';
239 +  if FProcName = '' then
240 +     IBError(ibxeNoStoredProcName,[nil]);
241    ActivateConnection;
242    Database.InternalTransaction.StartTransaction;
243 +  Params := TStringList.Create;
244    Query := TIBSQL.Create(self);
245    try
246      Query.Database := DataBase;
# Line 222 | Line 257 | begin
257        if (Query.Current.ByName('RDB$PARAMETER_TYPE').AsInteger = 0) then begin {do not localize}
258          if (input <> '') then
259            input := input + ', :' +
260 <            FormatIdentifier(Database.SQLDialect, Query.Current.ByName('RDB$PARAMETER_NAME').AsString) else {do not localize}
260 >            FormatParameter(Database.SQLDialect, Query.Current.ByName('RDB$PARAMETER_NAME').AsString) else {do not localize}
261            input := ':' +
262 <            FormatIdentifier(Database.SQLDialect, Query.Current.ByName('RDB$PARAMETER_NAME').AsString); {do not localize}
262 >            FormatParameter(Database.SQLDialect, Query.Current.ByName('RDB$PARAMETER_NAME').AsString); {do not localize}
263        end
264      end;
265      SelectSQL.Text := 'Execute Procedure ' + {do not localize}
266 <                FormatIdentifier(Database.SQLDialect, FProcName) + ' ' + input;
266 >                FormatParameter(Database.SQLDialect, FProcName) + ' ' + input;
267 > {   writeln(SelectSQL.Text);}
268    finally
269      Query.Free;
270 +    Params.Free;
271      Database.InternalTransaction.Commit;
272    end;
273   end;
# Line 266 | Line 303 | begin
303        else
304          DataType := ftFloat;
305      SQL_DOUBLE, SQL_FLOAT, SQL_D_FLOAT: DataType := ftFloat;
306 +    SQL_BOOLEAN:
307 +      DataType := ftBoolean;
308      SQL_TEXT: DataType := ftString;
309      SQL_VARYING:
310        if ((QSelect.Fields[i].AsXSQLVar)^.sqllen < 1024) then
# Line 300 | Line 339 | begin
339          DataType := ftBCD
340        else DataType := ftFloat;
341      SQL_DOUBLE, SQL_FLOAT, SQL_D_FLOAT: DataType := ftFloat;
342 +    SQL_BOOLEAN:
343 +      DataType := ftBoolean;
344      SQL_TEXT: DataType := ftString;
345      SQL_VARYING:
346        if ((QSelect.Params[i].AsXSQLVar)^.sqllen < 1024) then
# Line 431 | Line 472 | begin
472        case Params[j].DataType of
473          ftString:
474            SQLParams[i].AsString := Params[j].AsString;
475 <        ftBoolean, ftSmallint, ftWord:
475 >        ftSmallint, ftWord:
476            SQLParams[i].AsShort := Params[j].AsSmallInt;
477 +        ftBoolean:
478 +           SQLParams[i].AsBoolean := Params[j].AsBoolean;
479          ftInteger:
480            SQLParams[i].AsLong := Params[j].AsInteger;
481 < {        ftLargeInt:
482 <          SQLParams[i].AsInt64 := Params[j].AsLargeInt; }
481 >        ftLargeInt:
482 >          SQLParams[i].AsInt64 := Params[j].AsLargeInt;
483          ftFloat, ftCurrency:
484           SQLParams[i].AsDouble := Params[j].AsFloat;
485          ftBCD:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines