User Query Special Objects
Previous Topic  Next Topic 

A UserQuery special object produces a table on a diagram where the rows and columns are derived from the ControlDraw database by a query that is written into the UserText field of the symbol

In a UserQuery you can use clauses like Where Page ={CurrentPage}

For example a UserQuery with

Select Tagname, Class FROM qryPageObjects where Page ={CurrentPage}

will produce a list of the objects on the diagram and their classes

You can use {CurrentSymbolID} to get the IDD of the connected symbol so that you can link to and display data from other related tables.

For example "Select Stateno, Name as State from tblDynamics where SymbolID={CurrentSymbolID}"

You can use a Query from the Favourite User Queries by prefixing the name with FAV:

Use {CurrentSymbolTag} to get the Tagname of the connected symbol and {CurrentSymbolChildPage} to get the child page number.

{CurrentPageClass} returns the class number of the current page

{CurrentPageName} returns the tag name of the current page

{CurrentInstance} returns the instanceID of the currently selected page. So you can use

InstanceID Like "{CurrentInstance}.*"

in a user query, this make it possible to show data for each instance of a diagram. For example the IO addresses for each instance of a valve. To see this in ControlDraw, select a page instance and then redraw. This works even better in the Reviewer where you can now Print All Instances or a diagram with Real or External  tags and data.

Example Query (it needs attaching to an IO Object)

Select Card, Channel from qryClass17Instances where InstanceID Like "{CurrentInstance}.{CurrentSymbolID}"

For a UserQuery special object, if the text is positioned in the centre then the this query string is hidden, otherwise it is shown in the selected position.

With User Query special objects, if the resulting table has more than one record, and a field contains Line Feeds these are  replaced with ' : ' in order to keep the lines aligned. If there is only one record (eg Select Formula from tblDrawingObjects Where IDD={CurrentSymbolID}) then the complete text is shown.

Many Examples of User Queries are contained in the standard reference and sample models provided with ControlDraw.