Skip to content

docs: tweak prepare + execute page #32566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion doc/user/content/sql/execute.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,18 @@ Field | Use

## Example

The following example [prepares a statement](/sql/prepare/) `a` and runs it
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Later on (when I update the syntax to remove the rr diagram), I'll rename a to something else and will mention what it actually does.

using the `EXECUTE` statement:

```mzsql
EXECUTE a ('a', 'b', 1 + 2)
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`]
Expand Down
4 changes: 2 additions & 2 deletions doc/user/content/sql/prepare.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ statement | Any `SELECT`, `INSERT`, `UPDATE`, or `DELETE` statement.

Prepared statements can take parameters: values that are substituted into the statement when it is executed. The data type is inferred from the context in which the parameter is first referenced. To refer to the parameters in the prepared statement itself, use `$1`, `$2`, etc.

Prepared statements only last for the duration of the current database session. You can also delete them during a session with the `DEALLOCATE` command.
Prepared statements only last for the duration of the current database session. You can also delete them during a session with the [`DEALLOCATE`] command.

## Examples

Expand All @@ -34,7 +34,7 @@ PREPARE a AS SELECT 1 + $1;
### Execute a prepared statement

```mzsql
EXECUTE a ('a', 'b', 1 + 2)
EXECUTE a(2);
```

### Deallocate a prepared statement
Expand Down