Hi Julian,
i have modified procedure TDBWPEvalEngine.DoDBCommand to better support empty date/time field and some numeric field type, perhaps you can insert my little changes on standard WpReporter deployment.
wpdField: { Read the contents of the field }
begin
field := nil;
{ Concat the strings in the fields. At least one of the fields MUST be found }
if aFunction.ParamCount > 1 then
begin
s := '';
nall := '';
bool := FALSE;
for i := 0 to aFunction.ParamCount - 1 do
begin
n := aFunction.Params[i].StringValue;
if nall = '' then
nall := n
else
nall := nall + ',' + n;
if data.Active then
field := data.FindField(n);
if field <> nil then
begin
bool := TRUE;
s := s + field.AsString;
end;
end;
if bool then
aFunction.StringValue := s
else
aFunction.StringValue := Format(FFieldNotFoundText, [nall]);
end
else
{ There is only one parameter. Read the correct type for the field }
begin
try
s := aFunction.Params[1].StringValue;
if data.Active then
field := data.FindField(s)
else
field := nil;
if field = nil then
aFunction.StringValue := Format(FFieldNotFoundText, [s])
[start change 1]
// 22 Dic 2010 - Enrico - Data and time field changes
// else if field is TDateField then
// aFunction.DateValue := TDateField(field).AsDateTime
else if (field is TDateField) or (field is TDateTimeField) then
begin
if int(field.AsDateTime) = 0 then
aFunction.StringValue := ''
else
aFunction.StringValue := field.AsString;
end
// end date and time field changes
[end change 1]
else if field is TFloatField then
aFunction.FloatValue := TFloatField(field).AsFloat
else if field is TIntegerField then
aFunction.IntValue := TIntegerField(field).AsInteger
else if field is TBooleanField then
aFunction.BoolValue := TBooleanField(field).AsBoolean
[start change 2]
// 22 Dic. 2010 - Enrico - New numeric field type
else if field is TBCDField then
aFunction.FloatValue := TBCDField(field).AsFloat
else if field is TCurrencyField then
aFunction.FloatValue := TCurrencyField(field).AsFloat
else if field is TIntegerField then
aFunction.IntValue := TIntegerField(field).AsInteger
else if field is TSmallintField then
aFunction.IntValue := TSmallintField(field).AsInteger
else if field is TLargeintField then
aFunction.IntValue := TLargeintField(field).AsInteger
// end new numeric field type
[end change 2]
else
aFunction.StringValue := field.AsString;
except
{ Read error Text }
on ex: Exception do
begin
WPEVErrorMessage := ex.Message;
aFunction.StringValue := '<ERR: ' + ex.Message + '>';
try
aFunction.Error(0, 0);
except
{ we don't want an exceptin here ! }
end;
end;
else
raise ;
end;
end;
end;
wpdFirst :
Best regards,
Enrico
#1
♥ 0