-
Notifications
You must be signed in to change notification settings - Fork 0
pts database loop rawsql
Click Use raw SQL for the loop on the Insert DB Loop window to display the Raw SQL window. Read more: Command Syntax
|
|---|

This window allows you to perform more complex database queries. You can design your query using Microsoft Access if you prefer and then transfer it into the editor. The above query using multiple sorting on the record set.
It is assumed that you are already familiar with writing SQL queries and you use this facility at your own risk.
You must press Insert (or Update if editing an existing command) for your changes to be applied to the current script in the editor.
You can still save the row count to a variable, just like you can on regular loops.
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 (e.g.: '$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.
What you can do is design your SQL query from inside Microsoft Access. For example, the query shown above looks like this in Microsoft Access:

Once you have designed your query you can the SQL View in Microsoft Access to see what the query looks like:

You can then take this query and adapt it to correct syntax for the Custom Script Editor.
Copyright © 2002 - 2025 by Andrew Truckle. All Rights Reserved.
- Using Public Talks
- Main Application Menu
-
Database Ribbon Panel
- Assignments Editor
- Backup Database
- Check Talk Exchange
- Compact Database
- Convert Database
- Create Unassigned Date Entries
- Database Security
- Maintain Databases
- Purge Database
- Rearrange Dates
- Restore Database
- Help Ribbon Panel
-
Home Ribbon Panel
- Create a Report
-
Manage Custom Reports
- Editing Scripts
- Content Ribbon Panel
- System Ribbon Panel
- Script Command Syntax
-
Tutorials
- Using The Script Editor
-
How To Write Scripts
- Module 1 - The Basics
- Module 2 - Hello, World!
- Module 3 - Multiple Text Blocks
- Module 4 - It's A Date, Then
- Module 5 - Oh, I'm Blushing!
- Module 6 - It is a Rainbow!
- Module 7 - The Font Of All Knowledge
- Module 8 - Queue To The Right
- Module 9 - Memory Like An Elephant
- Module 10 - May I Squeeze In There?
- Module 11 - Move Over, Please
- Module 12 - You Move Over Here
- Module 13 - Is My Back A Funny Colour?
- Module 14 - I'm Going Loopy Here!
- Module 15 - Fields Of Golden... Text
- Module 16 - Man, That Looks Weird
- Module 17 - Inner Peace, Inner Loop
- Advanced Script Features
- Quick Access Toolbar
- Settings Ribbon Panel
- Tools Ribbon Panel
- Revision History
- Contact Information
Click Use raw SQL for the loop on the Insert DB Loop window to display the Raw SQL window. Read more: