|
You get to the Insert DB Loop dialogue by clicking the Insert DB Loop button on the script editor's control panel. |

Use the DB Loop dialogue to insert a LOOP into the custom report script file. A LOOP is used to walk through a list of rows in a specified database table one at a time until there are no more. This allows you to embed FIELD commands to print out contents of that row repeatedly.
To learn more about the features of this dialogue, glance down the table below or highlight the control you are interested in by clicking on the screenshot above. Please also remember that context help is available to you by either pressing F1 when the control has focus, or by using the question mark icon at the top right corner of the dialogue.
Please note that the RowNumber field is shared among all loops at this time. If you have nested loops, RowNumber will be correct for the outside loop before the nested loop, but not afterwards; it will change to be correct for the nested loop, and thus corrupt the outside version. To work around this, if you need the row number after the nested loop then simply use VARIABLE_FIELD to save it to a variable that you can use later.
Press this button to display the
raw SQL dialogue: This
dialogue allows you to perform more complex database queries.The example on the left uses table JOIN's to combine the results of two or more tables together. You can still save the row count to a variable, just like you can on regular loops. It is assumed that you are already familiar with writing SQL queries and you use this facility at your own risk. Since we're using raw SQL, standard SQL rules must apply: * Literal text and variables designed to hold such data (except dates) = single quotes * Literal dates and variables designed to hold dates = no delimiter (assumes date has been SQL formatted - if not, requires a hash each end) * Literal numbers (floating, integer or true / false) and variables designed to hold such data = no delimiter * Expression function parameters = double quotes (our functions require double quotes around strings, and also around dates (even if SQL formatted)). Notes: - You must specify the sort order yourself within the SQL query (if required). - You can use variables within your query. Don't forget to wrap them with ' ' if they relate to a textual comparison (eg: '$LocalCong'). - You use CURRENT."Field name" within your query. - You must not duplicate field names when performing table JOIN's. Use the SQL ALIAS command to ensure that each field in your resulting query is unique. |
|||||||||||||||||||
|
Use the dropdown listbox to select which table you want to retrieve information from to be used in the report. You can even select one of your own tables that you may have personally added into the database. |
|||||||||||||||||||
|
If you need to narrow down which records will be retrieved from the database, then you must add one or more criteria to this listbox. The available information would already be limited to the date range settings that were in effect when invoking the script editor. But you can override this by using the Ignore Date Range option (see below). You cannot directly edit this list, but have to use the 3 buttons to the right to add, edit or remove criteria. To see a working script using criteria, please view the Incoming Talk History Sample script which was installed with the program.
|
|||||||||||||||||||
|
Set this option to optionally sort the records retrieved. |
||||||||||||||||||
|
If you chose to sort the records, then this shows a list of fields for the chosen table. Simply choose the field you want to sort records by. | ||||||||||||||||||
|
Select this option if you want the records to be sorted in descending order (ie: Z to A). | ||||||||||||||||||
|
Setting this option will prevent the loop from using the date range specified when creating the report (or before entering the editor, if editing the script). This ensures all records will be retrieved. It is good for inner loops, where it is USUALLY only the outermost loop that you want to apply the date range to. Note, though, that the date range ONLY applies to Home Talks, Away Talks, Public Talk Titles and Congregations tables - it has no effect on any other table, even ones you may have added. It will be ignored for any other table. |
||||||||||||||||||
|
This is an advanced scripting feature
and should only be used if you have a good understanding of the
custom report scripting language. There are situations where you need to know how many rows (or records) are held in the LOOP and this is acheived by using a variable. Set the option Save row count to variable. Use the drop list to select your variable or type in a new dynamic variable. The resulting variable can be used anywhere inside the LOOP and anywhere after the LOOP. Detecting the last row in a LOOP Here is an example showing you how to detect the last row in a LOOP: ![]() |
||||||||||||||||||
|
|
Depending upon whether you are editing an existing loop or adding a new loop, this button will say Update or Insert. Press it to commit your changes into the script. | ||||||||||||||||||