logo


57.2.1 Query Store: Command: Query


Action of the command

Creates a Set and Selection of Records based on the Value field comparison.

Can be multiple lines long to create compound Queries - each line or lines is called a Query Block.

Can contain several distinct Query Blocks on the same form. A change in the Return set for the Table or another Command between Query Blocks signals the end of each Query block.

This will be the command that you will use most frequently.

After selecting Query from the drop down menu or after clicking on a Query line in the Query Display pane, you will see the Query editor controls:

 

Query: Command: Query: Controls

Return set for the Table

This drop down list allows you to specify which Master Table should be used to return a Set of records after the Query has completed. In the background this will also create a Selection for the same Table - this is more for backward compatibility with previously created Queries.

Take Care: If this is set to the wrong Table then you will get unexpected results.

We have found that the most common reason for failed Queries is because of inattention to this list.

E Button to Edit the Name of a Set

This button is described in “Query Store: E Button to edit Set Names” on page 431.

Causes for a failed Query due to Master Table error

Example of an impossible Query:

For instance if this list is set to [Bedstate] and the Query is on fields from the [HospitalRecord] Table then at the end of the Query your Set of records will contain Zero records even if the Query lines are all valid and correct.

Why?

Because at the end of the Query, STATIC will attempt to create a Set of records based on the [HospitalRecord] for the [Bedstate] table. As there is no relationship between the two tables, no records can be found in the [Bedstate] table, and so the Set of records returned is Zero.

Example of a possibly badly formed Query

For instance if this list is set to [HospitalRecord] and the Query is on fields from the [ICURecord] Table then at the end of the Query you will have created a [HospitalRecord] Set and not a [ICURecord] Set - this may not be what you want if you really wanted to create a [ICURecord] Set.

Why?

You have just performed a Cross Relational Query - this is a Query where you alter a Set of records in the Master Table based on the values in the records in a related Table.

Cross Relational Query

You can return a Set of records for the Table specified in Return set for the Table based on the value of a field that is related to this Table. This will be discussed later.

Note: If you select a Field belonging to a Table than t is different to the Table selected in the Return set for the Table drop down list then this list will automatically change to the Table of the Field selected. We have arranged the code in this way to protect you from unwanted Cross Relational Queries. Cross Relational Queries are rarely used and not recommended as there are faster, less error prone and easier to read ways of achieving the same thing using the Set and Join Set commands. If you really want to use this feature, then you have to select the Filed first and then the Return set for the Table drop down list item you require.

Conjunc.

This contains the three types of conjunctions available AND, OR, EXCEPT.

The conjunction is ignored for the first line of a Query Block - it can be set to whatever you want - it has no effect.

Field

The first list allows you to navigate to all tables that can be queried in STATIC. As you switch to different tables, the list of field names in the second drop down list changes accordingly. The field that you require can then be selected.

Note: The Type of the Field is displayed next to the A and Z Buttons.

If the Filed selected belongs to a Data Driven Table, an extra control called Data Driven Table Helper will appear that allows you to limit the fields displayed to the relevant ones for the actual Data Driven record required:

 

Query: Command: Query: Controls

The way this works is that any fields not used by the selected record type are not shown. Other fields are postfixed with the label specified for that field in the Define record for that Table. For instance in the case of Respiratory Support:

 

Query: Command: Query: Data Driven Table Controls: Respiratory Support example

Conversely in the case of Arterial Line:

 

Query: Command: Query: Data Driven Table Controls: Arterial Line example

The difference between the two is that Arterial Line is set to be a Discrete Event rather than, as in the case of Respiratory Support, a Duration Event. As a result many fields relevant for Duration events only are not displayed. In addition Respiratory Support collects Route and Type in the Data1 and Data2 fields. This is not required for Arterial Line. Note how in the case of Respiratory Support the Data1 and Data2 fields are postfixed with the actual label used for these two fields.

Argument

The Query argument (is equal to, is greater than, etc.) help to qualify the query. This is contextual i.e. it changes depending on the type of the field selected. For instance it does not make sense to use the <= argument with a text field so this does not appear when a text type field is selected.

A Query argument tells STATIC to “Compare each record to the value given, in the manner specified.” All of the records that satisfy the comparison, will become a part of the new selection.

Value

This area is where you type the value that you want STATIC to compare against when it is conducting the query. The Query Editor automatically adds a Wildcard when required. Therefore, if you need a Wildcard query, DO NOT manually add the wildcard when you type the value.

This area gives you prompts so that you enter correct information. Thus if a numeric value is expected only numeric values are allowed. Conversely if a time or date value is expected then this area will show a null value for time (00:00:00) and date (00/00/0000).

Note: The following information is for the benefit of users who use other 4th Dimension databases who are used to using the Wildcard symbol:

STATIC automatically prepends or appends the @ to the value being queried when it is required.

YOU DO NOT NEED TO ADD THIS SYMBOL IN THE QUERY EDITOR SUPPLIED WITH STATIC.

Doing so may confuse STATIC.

Field Description

A short text description of the field will show here.



Harrowex Pty Ltd
http://www.hxmedical.com
Voice:+ 61 4 27 344 279
Fax: +61 3 52 439 019
static@hxmedical.com