FunctionPackage: dbi.mysqlToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.2
Unrevised from 8.1 to 8.2.
8.1 version

insert-db

Arguments: cols-and-vals &key table db showsql

insert-db is a macro that creates an sql statement to insert a row into a table.

db should be a mysql object returned by connect. The value of *mysql* is a suitable value (and the default).

table specifies the table in the database into which the new row will be inserted. There is no meaningful default: you must specify a string naming a table as the value.

If showsql is specified true, the generated sql statement will be printed.

cols-and-vals specifies the columns and values. It looks like a let binding list:

cl-user(62): (insert-db ((val 20) 
                         (sq 400)) 
                        :table "square" 
                        :showsql t)
sql: (format nil "insert into square(val,sq) values(~a,~a)" 20 400)
nil
cl-user(63): 

If you are inserting a string or blob value you should specify a third value of :text in the cols-and-vals list.

cl-user(63): (sql "create table atext(ttt text)")
nil
cl-user(64): (insert-db ((ttt "foo" :text)) :table "atext")
nil

If you do not specify :text and and the value to be stored in the column is a string then the string is put in the sql statement verbatim. This is useful to store the value of mysql built-in functions.

cl-user(67): (insert-db ((val "now()") 
                         (sq "now()*now()")) 
                        :table "square")
nil
cl-user(68): 

See mysql.htm for information on the Allegro MySQL facility.


Copyright (c) 1998-2016, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 8.1 page.
Created 2010.1.21.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.2
Unrevised from 8.1 to 8.2.
8.1 version