UPDATE-RECORDS — Updates the values of existing records.Function
table
A string, symbol or symbolic SQL expression representing
the name of a table existing in
database.
attributes
A list of attribute identifiers or NIL.
values
A list of attribute values or NIL.
av-pairs
A list of attribute identifier/value pairs or NIL.
whereA symbolic SQL expression.
databaseA database object. This will default to the value of *default-database*.
Updates the attribute values of existing records satsifying
the SQL expression where in the table
specified by table in
database which defaults to
*default-database*.
There are three ways of specifying the values to update for
each row. In the first, values contains
a list of values to use in the update and
attributes and
av-pairs are NIL. This can be used
when values are supplied for all attributes in
table. In the second,
attributes is a list of column names,
values is a corresponding list of
values and av-pairs is NIL. In the
third, attributes and
values are NIL and
av-pairs is an alist of (attribute
value) pairs.
(select [first-name] [last-name] [email]
:from [employee]
:where [= [emplid] 1]
:field-names nil)
=> (("Vladimir" "Lenin" "lenin@soviet.org"))
(update-records [employee]
:av-pairs'((first_name "Yuri")
(last_name "Gagarin")
(email "gagarin@soviet.org"))
:where [= [emplid] 1])
=>
(select [first-name] [last-name] [email]
:from [employee]
:where [= [emplid] 1]
:field-names nil)
=> (("Yuri" "Gagarin" "gagarin@soviet.org"))
An error of type sql-database-data-error is
signalled if table is not an existing
table in database, if the specified
attributes are not found or if the SQL statement resulting
from the symbolic expression where does
not return a Boolean value.
If the execution of the SQL query leads to any errors, an error of type sql-database-error is signalled.