Use parameters
Last modified: March 28, 2025
What is a parameter?
Parameter is a placeholder for a variable that contains a value of some type that is passed to a database server along with the SQL text at the query execution time. Also parameter can hold values returned by a server after query or stored procedure execution.
You can benefit from using of parameters in the following situations:
-
When you execute a query multiple times with different input values.
-
When you debug a query from your application code.
Add parameters to a query text
There are two types of parameters that you can add to a query text:
-
Named parameter
-
Unnamed parameter
Named parameters
Parameters are declared using the :
prefix followed by name of the parameter.
For example:
SELECT
employee.*
FROM
hr.employee
WHERE
employee.title = :job AND
employee.vacation_hours <= :level
:job
and :level
are parameters in this query.
Unnamed parameters
Unnamed parameters can be specified with the ?
or $
symbol.
For example:
SELECT
employee.*
FROM
hr.employee
WHERE
employee.title = ? AND
employee.vacation_hours <= ?
Parameters for this query are created in the order of appearance.
Modify parameter values and types
When you run a query that contains parameters with empty values, you will be automatically prompted to initialize them.
To set parameter values and types, select Edit Parameters command from the SQL toolbar or main menu. In the Edit Parameters dialog that opens, set the type, value, and other properties for your parameters.