Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.
Custom SQL Fragments
You can create a Template Fragment to return data from an SQL Query. You do this by defining an SQL Query in the Document Options of the Template Fragment, then adding fields within the Custom section of your Template Fragment that refer to the columns returned by the SQL Query.
Create an SQL Query Fragment
Step |
Action |
See also |
---|---|---|
1 |
Open or create a Template Fragment in the Document Template Editor. |
|
2 |
In the Document Template Editor, right-click on the Template background and select File | Document Options. The Document Options dialog displays.
|
|
3 |
Select the Custom Query tab.
|
|
4 |
In the Template Fragment type panel, select the Custom SQL radio button.
|
|
5 |
In the main text field on the tab, type the SQL Query that is to be run on your model. This Query must return one or more columns; for example:
SELECT DocName AS TemplateName, Author AS TemplateLocation FROM t_document WHERE DocType = 'SSDOCSTYLE' and (IsActive = 1)
SELECT Count(Object_Type) AS CountOfActors FROM t_object WHERE Object_Type = "Actor" and Package_ID = #PACKAGEID#
|
|
6 |
Click on the OK button to close the Document Options dialog.
|
|
7 |
In the Document Template Editor, in the Sections panel, select the Custom checkbox to generate the Custom section.
|
|
8 |
Within the Custom section, right-click and select the Insert Custom Field context menu option. A prompt displays for the name of the field to create.
|
|
9 |
In response to the prompt, type the name of the column that is being returned by your Query; for example, CountOfActors. Click on the OK button.
|
|
10 |
Repeat steps 8 and 9 for each column that you want to include in your report. Add any other formatting and content you need, to the Template Fragment.
|
|
11 |
Save the Template Fragment, and add it to a normal document template. |
Adding Fragments to a Document Template
|
Notes
• | An Element Filter will not apply to the Custom section in a Template Fragment |
• | You can test your SQL Query using the SQL Editor in the Model Search window |
Learn more
Learning Center topics
• | Alt+F1 | Enterprise Architect | Reporting | RTF Template Fragments | |
• | Create a SQL based Fragment 1 |
• | Create a SQL based Fragment 2 |