Working with PostgreSQL Operations
Working with SQL Operations
Once your SQL Connection is configured, the next step is to define Operations—these are the specific queries your application will execute against the database. Operations in the Kinetic Platform use Prepared Statements to keep things secure, dynamic, and easy to test.
What Are SQL Operations?
An SQL Operation defines a query or statement that runs against your configured database connection. These operations:
- Use parameter placeholders (e.g.,
$1
,$2
, etc.) for dynamic input - Are defined in the admin UI (no need to write scripts)
- Can be used across forms, workflows, or logic nodes
- Are testable and reusable
Using Prepared Statements
SQL Operations use prepared statements, a secure way to insert values into a query without risking SQL injection.
Syntax
Use $1
, $2
, etc. to represent parameters in your SQL statement.
Example Query:
SELECT * FROM actor WHERE last_name LIKE $1
In this example:
$1
is a placeholder for a dynamic value (e.g., a last name typed by a user)- You’ll define what
$1
maps to in the Query Parameters section
Prepared statements improve security and performance and allow you to separate query logic from dynamic values.
Defining Query Parameters
Below the SQL editor, you’ll see the Query Parameters section. Here, you map each placeholder ($1
, $2
, etc.) to either:
- A hardcoded test value (for manual testing)
- A dynamic parameter using the
{{parameterName}}
format (for use in forms or workflows)
Example Mapping
Placeholder | Value |
---|---|
$1 | {{name}}% |
$2 | {{startDate}} |
The
{{name}}
syntax tells the platform to pull in a parameter from the form or workflow context at runtime.
Testing Your SQL Operation
Once parameters are mapped, click Run to test the query:
- The Results will appear in a table
- You can then switch to the Outputs tab to map specific fields from the result for use elsewhere
Example:
- Map
id
,first_name
, andlast_name
from a table of actor records - Use these outputs in a dropdown or pass values into a workflow
Example Use Cases
Dropdown Lists
Retrieve options for a form dynamically from a database view (e.g., locations, job titles, departments).
User-Based Routing
Fetch a user’s manager or role assignments from an internal HR or identity database.
Inventory Checks
Query asset counts or available licenses from a configuration management system.
Related Topics
Updated 1 day ago