Next Prev Up Top Contents Index

insert-records

Function
Summary

Inserts a set of values into a table.

Package

sql

Syntax

insert-records &key into attributes values av-pairs query database =>

Arguments

into

A database table.

values

A list of values or a query expression.

attributes

A list of attributes.

av-pairs

A list of two-element lists.

database

A database.

Values

None.

Description

The function insert-records inserts values for attributes (or av-pairs ) into the table into . The argument values may be a list of values or a query expression. If attributes is supplied then values must be a corresponding list of values for each of the listed attribute names.

The default value of database is *default-database* .

Example

In the first example, the LispWorks 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")))
See also

delete-records
update-records


LispWorks Reference Manual (Windows version) - 14 Dec 2001

Next Prev Up Top Contents Index