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); |
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 |
+ |
if FProcName = '' then |
239 |
+ |
IBError(ibxeNoStoredProcName,[nil]); |
240 |
|
ActivateConnection; |
241 |
|
Database.InternalTransaction.StartTransaction; |
242 |
+ |
Params := TStringList.Create; |
243 |
|
Query := TIBSQL.Create(self); |
244 |
|
try |
245 |
|
Query.Database := DataBase; |
256 |
|
if (Query.Current.ByName('RDB$PARAMETER_TYPE').AsInteger = 0) then begin {do not localize} |
257 |
|
if (input <> '') then |
258 |
|
input := input + ', :' + |
259 |
< |
FormatIdentifier(Database.SQLDialect, Query.Current.ByName('RDB$PARAMETER_NAME').AsString) else {do not localize} |
259 |
> |
FormatParameter(Database.SQLDialect, Query.Current.ByName('RDB$PARAMETER_NAME').AsString) else {do not localize} |
260 |
|
input := ':' + |
261 |
< |
FormatIdentifier(Database.SQLDialect, Query.Current.ByName('RDB$PARAMETER_NAME').AsString); {do not localize} |
261 |
> |
FormatParameter(Database.SQLDialect, Query.Current.ByName('RDB$PARAMETER_NAME').AsString); {do not localize} |
262 |
|
end |
263 |
|
end; |
264 |
|
SelectSQL.Text := 'Execute Procedure ' + {do not localize} |
265 |
< |
FormatIdentifier(Database.SQLDialect, FProcName) + ' ' + input; |
265 |
> |
FormatParameter(Database.SQLDialect, FProcName) + ' ' + input; |
266 |
> |
{ writeln(SelectSQL.Text);} |
267 |
|
finally |
268 |
|
Query.Free; |
269 |
+ |
Params.Free; |
270 |
|
Database.InternalTransaction.Commit; |
271 |
|
end; |
272 |
|
end; |
471 |
|
SQLParams[i].AsShort := Params[j].AsSmallInt; |
472 |
|
ftInteger: |
473 |
|
SQLParams[i].AsLong := Params[j].AsInteger; |
474 |
< |
{ ftLargeInt: |
475 |
< |
SQLParams[i].AsInt64 := Params[j].AsLargeInt; } |
474 |
> |
ftLargeInt: |
475 |
> |
SQLParams[i].AsInt64 := Params[j].AsLargeInt; |
476 |
|
ftFloat, ftCurrency: |
477 |
|
SQLParams[i].AsDouble := Params[j].AsFloat; |
478 |
|
ftBCD: |
556 |
|
Reader.ReadCollection(Params); |
557 |
|
end; |
558 |
|
|
559 |
< |
end. |
559 |
> |
end. |