Prev | Next |
How to Define a Custom SQL Fragment
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. The Query is DBMS dependent and so might vary according to the DBMS you are using.
Create an SQL Query Fragment
Step |
Action |
See also |
---|---|---|
1 |
Open or create a Template Fragment in the Document Template Editor. |
Document Templates Creating a Template Fragment |
2 |
In the Document Template Editor:
|
Document Options |
3 |
In the main text field on the tab, type the SQL Query that is to be run on your model. For more details see the Create a Custom SQL Query Help topic. |
Create a Custom SQL Query |
4 |
Click on the to close the 'Document Options' dialog. |
|
5 |
In the 'Document Template Editor', in the 'Sections' panel, select the 'Custom' checkbox to generate the 'Custom' section. |
Setting Sections for Reporting |
6 |
Within the 'Custom' section, right-click and select the 'Insert Custom Field' option. A prompt displays for the name of the field to create. |
|
7 |
In response to the prompt, type the name of the column that is being returned by your Query; for example, Note.Formatted. Click on the . |
|
8 |
Repeat steps 6 and 7 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 |