For a general introduction to queries see What are queries?

The KB can be used to store queries and query menus. The query menus will automatically be included in the menu-bar in PRO3.EXE (you have to exit and re-enter PRO3.EXE for this to happen). The purpose is to provide a simple of way running often-used queries. Pro/3 has a standard set of queries covering queries relating to terminology, sentence model and knowledge dependencies. These queries and query menus can be loaded from PRO3-x-Q1.3PR. 

Queries and query menus are represented as sentences in the KB. Three sentence types are involved:

NL KB
KB-query is in the model y|p3_eKbq
query menu is in the model y|p3_eKbm
query parameter is in the model y|p3_eKbp

Generally queries and query menus form a hierarchical structure with a system-defined root-menu with menu-ID 7000 (corresponding to the menu entry Query in the MDI-windows menu toolbar). First-level sub-menus and queries have menu 7000 as owner. You can define several layers of sub-menus of you so wish. Menu-IDs and query IDs are limited to the range 8001-8999. Pro/3 standard menus and queries use IDs in the 7001-7999 range. 

To avoid referential integrity warnings you must enter sub-menus before you enter queries under these menus, and similarly you must enter query parameters before you enter queries that use them. Query clusters must be entered after all the queries in the cluster has been entered.

Queries belong to a menu, so you will have to define at least one query menu before you attempt to store queries in the KB. Query parameters are optional. The user will be prompted for actual values of the parameters when the query is run. A predefined set of alternative parameter values can optionally be defined.

KB-QUERY RELATED ENTITY TYPES

The query menu entity type:

DATA ELEMENT NAME (NL) DOMAIN VALUE
menu-ID INTEGER Windows control number (use numbers in the range 8000-8999)
language IDENTIFIER Language
menu name STRING The menu item's menu text
owner menu INTEGER Windows control number (use numbers in the range 8000-8999)

Example:

query menu with menu-ID 8100, language English, menu name "Motorcycles" and owner menu 7000 is in the model !

The KB- query entity type:

DATA ELEMENT NAME (NL) DOMAIN VALUE
menu- ID INTEGER Windows control number (use numbers in the range 8000-8999)
language IDENTIFIER Language
menu name STRING The query's menu text
format IDENTIFIER NL or PR
query text STRING The query (corresponding to format) *
owner menu INTEGER Windows control number (use numbers in the range 8000-8999)

Example:

KB-query with menu-ID 8105, language English, menu name "Manufacturer`s country", format NL, query text "which motorbikes are made in which countries" and owner menu 8100 is in the model !
 

Notes!

  • * Do not terminate the query text with a question mark, in compliance with the general rule of avoiding special characters in string literals.
  • Note the use of ` in place of ' in Manufacturer`s country , since apostrophes are not allowed in string.
  • Since quotes are not allowed inside strings, it is not possible to store KB-query's which include string literals e.g. as a part of a condition.

Parameters can optionally be embedded in a query. The user will be prompted for the desired actual parameter value each time the query is run. Embedding is done by including the parameter name in curly brackets:

Examples:

  • KB-query with menu-ID 8152, language English, menu name "Specifications", format NL, query text "which motorbike with model name=[model] have metric specifications" and owner menu 8150 is in the model !
  • KB-query with menu-ID 8201, language English, menu name "Bikes of given type", format NL, query text "which motorbikes have type with type=[type]" and owner menu 8200 is in the model !
     

The query parameter entity type:

DATA ELEMENT NAME (NL) DOMAIN VALUE
parameter name STRING A unique name assigned to the parameter. The name cannot include blanks.
language IDENTIFIER Language
domain name IDENTIFIER The answer value domain.
title STRING The title (prompt) which will be used in the dialog for entry of the actual parameter value.
alternatives LIST OF STRINGS A possibly empty list of actual parameter alternatives (from which the user can choose)

Examples:

  • query parameter with parameter name "model", language English, domain name STRING, title "Model" and no alternatives is in the model !

  • query parameter with parameter name "type", language English, domain name IDENTIFIER, title "Type" and alternatives "sportsbike", "trailie", "all-round", "cruiser", "roadster", "sports tourer" and "tourer" is in the model !

     

Note that PR-format queries require actual parameters (and alternatives if specified) in PR-format, while NL-format queries correspondingly require actual parameters in NL-format. For this reason, it is generally a good idea to define queries with parameters in NL-format.

QUERY CLUSTERS

You can also create a cluster of queries which are executed together. The user will be prompted for actual parameter entry only once if the queries share parameters. A query cluster is entered as a query, however the query text data element is used to specify the queries in the cluster. The queries are identified by their menu-ID and separated by semicolon.

Example:

KB-query with menu-ID 8151, language English, menu name "ALL", format NL, query text "8152;8153" and owner menu 8150 is in the model !

QUERY PARAMETER PROMPTS

The user will be prompted for the desired actual parameter value each time a parameterized query is run. There is one dialog for parameters where no value alternatives are defined, and one for parameters with defined value alternatives: