# Prepared statements

A prepared statement separates SQL structure from positional parameter values. Prepare one statement, then supply a new Value slice each time it is executed.

Missing bindings are errors. The API prepares a statement for the application; it does not define a stored procedure. SQL CREATE PROCEDURE and SQL PREPARE/EXECUTE are not supported.

## Prepare and bind

An application using the coordinator crate can open a connection and bind values:

```rust
use coordinator::{Connection, Value};

fn main() -> coordinator::Result<()> {
    let mut db = Connection::open_in_memory()?;
    db.execute("CREATE TABLE people(id INTEGER PRIMARY KEY,name TEXT)")?;
    let insert = db.prepare("INSERT INTO people VALUES (?1,?2)")?;
    db.execute_prepared(&insert, &[Value::Integer(1), Value::Text("Ada".into())])?;
    let find = db.prepare("SELECT name FROM people WHERE id=?1")?;
    let result = db.query_prepared(&find, &[Value::Integer(1)])?;
    assert_eq!(result.rows[0][0].scalar_text(), "Ada");
    Ok(())
}
```

## Connection and interfaces

Use `Connection::open(path)` for a file-backed database. The example uses an in-memory database so the parameter and result behavior can be tried independently.

A native parameter request can carry values beside SQL. The ordinary CLI and HTTP request options do not provide a parameter-binding interface; an application should use a supported binding API rather than inserting data values into SQL text.

See [deployment modes](https://coordinatordb.com/docs/get-started/about/deployment-modes) for embedded connection scope.
