INSERT-RECORDS — Insert tuples of data into a database table.
Function
A string, symbol or symbolic SQL expression representing the name of a table existing in database.
A list of attribute identifiers or NIL.
A list of attribute values or NIL.
A list of attribute identifier/value pairs or NIL.
A query expression or NIL.
A database object. This will default to the value of *default-database*.
Inserts records into the table specified by into in database which defaults to *default-database*.
There are five ways of specifying the values inserted into each row. In the first values contains a list of values to insert and attributes, av-pairs and query are NIL. This can be used when values are supplied for all attributes in into. In the second, attributes is a list of column names, values is a corresponding list of values and av-pairs and query are NIL. In the third, attributes, values and query are NIL and av-pairs is an alist of (attribute value) pairs. In the fourth, values, av-pairs and attributes are NIL and query is a symbolic SQL query expression in which the selected columns also exist in into. In the fifth method, values and av-pairs are nil and attributes is a list of column names and query is a symbolic SQL query expression which returns values for the specified columns.
(select [first-name] [last-name] [email] :from [employee] :where [= [emplid] 11] :field-names nil) => NIL (insert-records :into [employee] :attributes '(emplid groupid first_name last_name email ecompanyid managerid) :values '(11 1 "Yuri" "Gagarin" "gagarin@soviet.org" 1 1)) => (select [first-name] [last-name] [email] :from [employee] :where [= [emplid] 11] :field-names nil) => (("Yuri" "Gagarin" "gagarin@soviet.org"))