# EXECUTE
`EXECUTE`

> For the complete documentation index, see [llms.txt](https://preview.materialize.com/materialize/40269/llms.txt).


`EXECUTE` plans and executes [prepared statements](https://preview.materialize.com/materialize/40269/markdown-docs/sql/prepare/index.md). Since prepared statements only last the duration of a session, the statement must have been prepared during the current session.

If the `PREPARE` statement specified some parameters, you must pass values compatible with those parameters to `EXECUTE`. Values are considered compatible here when they can be [_assignment cast_](https://preview.materialize.com/materialize/40269/markdown-docs/sql/functions/cast/index.md#valid-casts). (This is the same category of casting that happens for `INSERT`.)


## Syntax



```mzsql
EXECUTE <name> [ ( <parameter> [, ...] ) ]

```

| Syntax element | Description |
| --- | --- |
| `<name>` | The name of the prepared statement to execute.  |
| `<parameter>` | The actual value of a parameter to the prepared statement.  |


## Example

The following example [prepares a statement](https://preview.materialize.com/materialize/40269/markdown-docs/sql/prepare/index.md) `a` and runs it
using the `EXECUTE` statement:

```mzsql
PREPARE a AS SELECT 1 + $1;
EXECUTE a (2);
```

All prepared statements will be cleared at the end of a session. You can also
explicitly deallocate the statement using [`DEALLOCATE`].


## Related pages

- [`PREPARE`]
- [`DEALLOCATE`]

[`PREPARE`]:https://preview.materialize.com/materialize/40269/markdown-docs/sql/prepare/index.md
[`DEALLOCATE`]:https://preview.materialize.com/materialize/40269/markdown-docs/sql/deallocate/index.md
