Prev | Next |
Create a Custom SQL Query
When defining your own SQL statement for a template fragment there are a number of options available to assist in delivering the desired reporting format. The query is DBMS dependent, so the structure can vary according to the specific repository file or DBMS-type that you are using.
Query Options
Option |
Description |
See also |
---|---|---|
Macro Substrings |
In the main text field on the tab, type the SQL Query that is to be run on your model. You can use #<macro>#s as string substitutions, as for other SQL Search Queries. The SQL Query can reference the ID of the element, diagram or Package currently being processed by the document template, using the macros:
For example:
There are a number of other useful macros like:
For more details see the Create Search Definitions Help topic. |
Create Search Definitions |
Formatted Notes (excluding .eap) |
For notes fields, like the Element Notes (t_object.note), the formatting is stored as rich text. It is possible for a note field to be processed from raw data to readable rich text by providing a column in this format: {<fieldname>.Formatted} This is defined in the Custom section in the Template. For example:
In your custom SQL Query statement, you must use an alias matching the template field name; for example (in MySQL):
|
|
Formatted Notes for .eap repositories |
For formatted notes using .eap file repositories the format requires: {<fieldname>.Formatted} For example:
In your custom SQL Query statement format the field-alias as '[<fieldname>-Formatted]'. For example:
|
|
Hyperlinks (excluding .eap) |
You can make column entries into hyperlinks referencing other entries in the generated document. The column header field (in the template text, in the 'Custom' panel) must use the format: <fieldname>.Hyperlink For example:
The SQL column entries, or values, must have the format: {guid}<LABEL> For example:
Note: this uses the #Concat ...# to concatenate the GUID reference and the outward expression of the hyperlink. In this format, {guid} is the GUID of the element to link to and LABEL is the hyperlink text (such as the element name), either manually inserted or returned from another command. For example: {570CFDAB-00A4-48d9-AE87-9CD6920418C0}Class2 In the generated report this displays as a hyperlink 'Class2', which links to the description of Class2 in the document. This example returns the hyperlinked name of each base (parent) Class of the element currently being reported:
This query could return multiple entries, in which case the entries are reported one per line. You can, if required, have multiple Hyperlink query statements, separated by commas. You can hyperlink to reported elements, attributes, operations, diagrams and Packages. |
Create Search Definitions |
Hyperlinks for.eap repositories |
The Hyperlink field name format for .EAP repositories requires:
And the SQL uses: [<fieldname>-Hyperlink]:
|
Notes
- An element will not apply to the 'Custom' section in a Template Fragment
- In your SQL statements you can reference model details using:
- #OBJECTID# returns the ID of the element currently being processed by the document template
- #PACKAGEID# and #Package# return the ID of the Package currently being
processed by the document template
- #Author# takes the user name from the 'Author' field in the 'General' page of the
'Preferences' dialog, so the defined search can be performed on objects created
by that user (this value can be manually re-set in the 'Preferences' dialog) - You can test your SQL Query using the SQL Editor in the Find in Project window