Custom SQL Fragments

You can create an RTF 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 RTF Editor.

RTF Templates

Creating an RTF Template Fragment

 

2

In the 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)

 

 

 

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.

 

Setting Sections for Reporting

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: TemplateName.

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 standard RTF Template.

Adding Fragments to an RTF Template

 

Notes

An Element Filter will not apply to the Custom section in an RTF Template Fragment
You can test your SQL Query using the SQL Editor in the Model Search window

Learn more

Learning Center topics

(Alt+F1) | Reporting | RTF Template Fragments |
Create a SQL based Fragment 1
Create a SQL based Fragment 2