Generic function
Prepares an SQL statement for execution on the specified connection and then executes the statement.
execute sql-statement #key connection parameters result-set-policy liaison => result-set
<sql-statement>.
<connection>.
false-or(<sequence>).
false-or(<result-set-policy>).
false-or(<function>) whose signature is liaison(<record>) => <object>. Default value: default-liaison.
false-or(<result-set>).
sql
sql
Prepares the SQL statement represented by sql-statement for execution on the connection, then sends it to the DBMS for execution.
If connection is not supplied, execute uses the connection returned by default-connection instead.
The liaison function is invoked on each record as it is retrieved from the database. If a liaison function is not provided, a default value of default-liaison is used; each result-set class has its own default-liaison.
In the SQL-ODBC library, the database-statement will be an instance of <sql-statement>. If anonymous host variables--that is, question marks (?)--appear in database-statement, pass suitable substitution values in the call to this function.
Example:
This example executes two SQL statements against the database represented by the-connection. The first SQL statement inserts a new book record into the book table. The second SQL statement queries for the list of titles and their ISBN published by Addison Wesley.
with-connection(the-connection)
let insert-stmt :: <sql-statement> =
make(<sql-statement>,
text: "insert into book (title, publisher, isbn)
values (?, ?, ?)",
input-indicator: $null-value);
execute(insert-stmt,
parameters: #("Large Databases", "Addison-Wesley",
$null-value));
let query-stmt :: <sql-statement> =
make(<sql-statement>,
text: "select title, isbn from book
where publisher = ?",
output-indicator: $null-value);
execute(query-stmt, parameters: #("Addison-Wesley"));
end with-connection;
=> #(#("An Introduction to Database Systems", "0-201-14201-5"),
#("Relational Database Writings, 1991-1994", "0-8053-1748-1), #("Large Databases", $null-value))