Next Prev Up Top Contents Index

insert-records

Function
Summary

Inserts a set of values into a table.

Package

sql

Signature

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

Arguments

into

A database table.

values

A list of values, or nil

attributes

A list of attributes, or nil

av-pairs

A list of two-element lists, or nil .

query

A query expression, or nil .

database

A database.

Values

None.

Description

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* .

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 - 25 Jul 2003

Next Prev Up Top Contents Index