> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

> Reference material for PARAM function

# PARAM

<Note>
  For most use cases, consider using [parametrized queries](/guides/sql-dialect/parametrized-queries) with `$1`, `$2`, ... placeholders instead. They provide a simpler syntax, prevent SQL injection, and are supported across all Firebolt SDKs and drivers.
</Note>

Evaluates a provided query parameter and returns its value as `TEXT`.

## Syntax

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
PARAM(<parameter>)
```

| Parameter     | Description                                                             | Supported input types |
| :------------ | :---------------------------------------------------------------------- | :-------------------- |
| `<parameter>` | Constant string containing the name of the query parameter to evaluate. | `TEXT`                |

## Return Type

`TEXT`

## Specifying query parameters

To use the `PARAM` function, you need to define query parameters using the `SET query_parameters` command.
The function relies on a request property named `query_parameters` in JSON format. Use the following schema:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
query_parameters: json_array | json_object
json_array: [ json_object, … ]
json_object: { "name" : parameter_name, "value" : parameter_value }
```

You can include a single query parameter in the request properties, for example:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{ "name": "country", "value": "USA" }
```

or multiple query parameters:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
[ 
  { "name": "country", "value": "USA" },
  { "name": "states", "value": "WA, OR, CA" },
  { "name": "max_sales", "value": 10000 }
]
```

## Example

The following example shows how to use a Common Table Expression (CTE), through a `WITH` clause, to generate input data and apply a query parameter in a computation.
The `WITH` clause defines a temporary dataset, and the query evaluates whether each row matches the parameter value using `PARAM`.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SET query_parameters = [{ "name": "track_name", "value": "Nürburgring" }];

WITH fastest_laps(name, difficulty, fastest_lap, driver) AS (
  SELECT 'Monaco', 'Hard', '1:10.166', 'Lewis Hamilton'
  UNION ALL
  SELECT 'Silverstone', 'Medium', '1:27.097', 'Max Verstappen'
  UNION ALL
  SELECT 'Nürburgring', 'Easy', '1:29.468', 'Valtteri Bottas'
)
SELECT *
FROM fastest_laps
WHERE name = PARAM('track_name');
```

**Returns**

| name        | difficulty | fastest\_lap | driver          |
| ----------- | ---------- | ------------ | --------------- |
| Nürburgring | Easy       | 1:29.468     | Valtteri Bottas |
