Home RAP
New Blog Posts: Merging Reports - Part 1 and Part 2

RAP invalid dbfield names should give an error

Referencing fields as pipelinename['fieldname'] should give a error if the field or pipe does not exist. This is important if the dataset SQL is changed.

Can there perhaps be a property on the report to set strict?

Lawrence

Comments

  • Hi Lawrence,

    Thanks for the feedback. Are you referring to a compiler error or runtime error? An error is given at runtime when the field name is incorrect however it is not very descriptive. We will look at providing a more useful runtime error when a field name does not exist.

    I do not believe Delphi gives a compiler error when field names are incorrect but we'll add this to our list of possible enhancements for RAP.
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • Thanks. I have not tested it yet with 22.03 but I was considering 19.* which just seemed to overlook it and return empty.

    Have I got that right?

    Lawrence
  • Sorry, it was a runtime thing with no error presented.

    Lawrence
  • I have a simple report, and changed the fields for some
    DBTEXT objects.

    It printed / previewed with no errors messages showing.


    Lawrence
  • ** Hi there, can you help **
  • Hi Lawrence,

    This is working as designed. After further research, the error I was receiving in my test app was due to a type mismatch and was not directly related to the incorrect field name per se. We will consider adding a descriptive runtime error to RAP when the field name is not found for a future release of ReportBuilder.
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • That would be good, both for dbtext fields and pipes as well as d := pipename['field']

    Are you confirming that this behaviour does not happen in the current version.

    Is there a patch that I might have to do it?

    Thank you

    Lawrence
  • For checking reports after a database redesign I used following code to find fields referencing obsolete database fields. Maybe it's of use for you.

    class procedure TDigitalMetaphors.DetectMissingFields(const AReport: TppCustomReport; const AReportName: string);
    var
    Datapipeline: TppDataPipeline;
    SubReport: TppSubReport;
    Component: TppComponent;
    ComponentName: string;
    SubReportName: string;
    BandIdx: integer;
    ObjIdx: integer;
    Band: TppBand;
    begin
    // #1626 iterate bands, design layers and subreports. Crosstab is not checked
    for BandIdx := 0 to AReport.BandCount-1
    do begin
    Band := AReport.Bands[BandIdx];
    for ObjIdx := 0 to Band.ObjectCount-1
    do begin
    Component := Band.Objects[ObjIdx];
    if (Component is TppSubReport)
    then begin
    SubReport := TppSubReport(Component);

    if (AReportName <> '')
    then SubReportName := AReportName + '.' + SubReport.UserName
    else SubReportName := SubReport.UserName;

    // recursive into subreport
    DetectMissingFields(SubReport.Report, SubReportName);
    end
    else if Component.IsDataAware
    then begin
    Datapipeline := Component.DataPipeline;
    if Assigned(Datapipeline) and (Component.DataField <> '')
    then begin
    if not Assigned(DataPipeline.GetFieldForName(Component.DataField))
    then begin
    // generate error
    if (AReportName <> '')
    then ComponentName := AReportName + '::' + Band.GetDescription + '::' + Component.UserName
    else ComponentName := Band.GetDescription + '::' + Component.UserName;

    raise EUserException.CreateFmt('%s contains a reference to %s.%s', [ComponentName,Datapipeline.Name,Component.DataField]);
    end;
    end;
    end;
    end;
    end;
    end;
    Kind regards,

    Jeroen Röttink
    JR-soft software solutions
Sign In or Register to comment.