HomeActive Query Builder - Metadata handling and filtrationWorking with metadata in .NET versionHow to detect incorrect object and field names in the query?

1.7. How to detect incorrect object and field names in the query?

On parsing a query, the component gets objects listed in the FROM clause of the query and tries to find a corresponding objects in the Metadata Container. Of course, the Metadata Container should be properly filled with database objects to find a correspondence. This can be done by connecting Active Query Builder to live database connection or you can pre-load the Metadata Container from the XML file.

There are two collections that lists objects and fields in the query: QueryBuilder.QueryStatistics.UsedDatabaseObjects and QueryBuilder.QueryStatistics.UsedDatabaseObjectFields. Each item in these collections has the MetadataObject property that refers to the MetadataItem object contained in the MetadataContainer. If an item has null reference in the MetadataObject property, this may indicate that this object does not really exist in the database.

Another reason of failure might be that objects the query are typed with omitted database or schema names, while the appropriate database and schema objects is not properly marked as default in the Metadata Container. This is usually happens when the query was written on behalf of another database user. In this case the database server itself will fail to execute such a query.

For some reasons you may want to deny parsing of queries with incorrect object names by setting the QueryBuilder.BehaviorOptions.ParsingErrorOnUnknownObjects property to True.

This page was: Helpful | Not Helpful