ClearBindings - Maple Help

Database[SQLite]

 ClearBindings
 reset bindings in a prepared SQL statement

 Calling Sequence ClearBindings( statement )

Parameters

 statement - prepared SQL statement obtained using the Prepare command

Description

 • The ClearBindings command resets value bindings for parameters in a prepared SQL statement.

Examples

 > $\mathrm{with}\left(\mathrm{Database}\left[\mathrm{SQLite}\right]\right):$
 > $\mathrm{connection}≔\mathrm{Open}\left(":memory:"\right):$
 > $\mathrm{Execute}\left(\mathrm{connection},"CREATE TABLE test \left(val\right)"\right):$
 > $\mathrm{stmt}≔\mathrm{Prepare}\left(\mathrm{connection},"INSERT INTO test VALUES \left(?\right)"\right)$
 ${\mathrm{stmt}}{≔}{"SQLite statement"}{,}{"INSERT INTO test VALUES \left(?\right)"}$ (1)
 > $\mathrm{Bind}\left(\mathrm{stmt},1,"value 1"\right)$
 > $\mathrm{Step}\left(\mathrm{stmt}\right):$

Execute statement again without clearing - the "value 1" is inserted

 > $\mathrm{Reset}\left(\mathrm{stmt}\right)$
 > $\mathrm{Step}\left(\mathrm{stmt}\right):$
 > $\mathrm{Reset}\left(\mathrm{stmt}\right)$

Clear bound value and bind a new one

 > $\mathrm{ClearBindings}\left(\mathrm{stmt}\right)$
 > $\mathrm{Bind}\left(\mathrm{stmt},1,"value 2"\right)$
 > $\mathrm{Step}\left(\mathrm{stmt}\right):$
 > $\mathrm{Finalize}\left(\mathrm{stmt}\right):$
 > $\mathrm{stmt}≔\mathrm{Prepare}\left(\mathrm{connection},"SELECT * FROM test"\right)$
 ${\mathrm{stmt}}{≔}{"SQLite statement"}{,}{"SELECT * FROM test"}$ (2)
 > $\mathrm{FetchAll}\left(\mathrm{stmt}\right)$
 $\left[\begin{array}{c}{"value 1"}\\ {"value 1"}\\ {"value 2"}\end{array}\right]$ (3)
 > $\mathrm{Finalize}\left(\mathrm{stmt}\right):$
 > $\mathrm{Close}\left(\mathrm{connection}\right):$

Compatibility

 • The Database[SQLite][ClearBindings] command was introduced in Maple 18.