A database table.
A list of values, or nil
A list of attributes, or nil
A list of two-element lists, or nil
.
A query expression, or nil
.
A database.
The function insert-records
inserts records into the table into.
The records created contain values for attributes (or av-pairs). The argument values is a list of values. If attributes is supplied then values must be a corresponding list of values for each of the listed attribute names.
If av-pairs is non-nil, then both attributes and values must be nil
.
If query is non-nil, then neither values nor av-pairs should be. query should be a query expression, and the attribute names in it must also exist in the table into.
The default value of database is *default-database*.
In the first example, the Lisp expression
(insert-records :into [person]
:values '("abc" "Joe" "Bloggs" 10000 3000 nil
"plumber"))
is equivalent to the following SQL:
INSERT INTO PERSON
VALUES ('abc','Joe',
'Bloggs',10000,3000,NULL,'plumber')
In the second example, the LispWorks expression
(insert-records :into [person]
:attributes '(person_id income surname occupation)
:values '("aaa" 10 "jim" "plumb"))
is equivalent to the following SQL:
INSERT INTO PERSON
(PERSON_ID,INCOME,SURNAME,OCCUPATION)
VALUES ('aaa',10,'jim','plumb')
The following example demonstrates how to use :av-pairs
.
(insert-records :into [person] :av-pairs
'((person_id "bbb") (surname "Jones")))
LispWorks User Guide and Reference Manual - 13 Feb 2015