Set up Local Queries
Introduction to Local Queries
When you use Scripting to query a local database using the LocalDatabaseConnection.execute() method, you must create each database query as a Local Query in GS.
The LocalDatabaseConnection.execute() method will reference the ID of a Local Query.
A Local Query can perform any type of query — SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, EXEC, and so forth.
If you want your Script to pass runtime values in to the Local Query, enter ? as a placeholder for each of these values in the Local Query. When using the LocalDatabaseConnection.execute() method in your Script, set the parameters argument to an array of actual values to bind into the Local Query.
Creating, editing, or viewing Local Queries
To create, edit, or view a Local Query:
- On the navigation menu
, expand the Setup
section. Then select Local Queries.
- This displays a list of all the Local Queries (and the ID for each Local Query, which you will reference in your Script).
- To create a Local Query, select the Add button.
- To edit a Local Query, select the Edit
button for that Local Query.
- To view a Local Query, select the View
button for that Local Query.
- To edit a Local Query, select the Edit
- Set or change the Required settings (below) for that Local Query.
- Select the Save button at the top or bottom of the page to save your changes.
Required settings
Name
Each Local Query must have a unique name.
You can translate this into another language (Spanish or English).
Query
A Local Query can perform any type of query — SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, EXEC, and so forth.
If you want your Script to pass runtime values in to the Local Query, enter ? as a placeholder for each of these values in the Local Query. When using the LocalDatabaseConnection.execute() method in your Script, set the parameters argument to an array of actual values to bind into the Local Query.
Translating text into another language
- To translate a text field into another language (Spanish or English), select its Translate
button.
- Enter your translated text, then select the Save button at the top or bottom of the window.
- For more information on translating text fields and changing the language displayed to the user, see Custom Translations.
Copying a Local Query
You can copy a Local Query to a new Local Query name. To do so:
- On the list of Local Queries, select the View
button for the Local Query you want to copy.
- Select the Copy button.
- Enter a New Name for the new Local Query, and then select the Copy button.
- Edit any settings for this new Local Query.
Using a spreadsheet to create and edit Local Queries
You can use a spreadsheet (.csv file) to create or edit multiple Local Queries and then import them.
This can be much faster and easier than creating or editing those Local Queries one at a time in GS.
Deleting a Local Query
You should only delete Local Queries that are not used by any Scripts.
To delete a Local Query that is not being used:
- On the list of Local Queries, select the View
button for the Local Query you want to delete.
- Then select the Delete button
at the top of the page.