MacroPackage: dbi.mysqlToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 9.0
Unrevised from 8.2 to 9.0.
8.2 version

update-db

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

This macro creates an sql update statement. update can alter zero or more rows in a table or tables. The syntax of update-db combines the cols-and-vals from insert-db and the where argument from with-db-rows.

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 to update. 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.

A simple example to zero the order id in the customer table for a given custid (customer id):

(update-db ((orderid 0))
           :table (store-customer store)
           :where (= u_customer custid)
           :db db)

A more complex example where we use the fact that a string value to store is inserted verbatim in the sql statement:

(update-db ((quantity quantity)
            (totalcost
             (format nil "~a*~a" quantity price))
            (totalweight
             (format nil "~a*~a" quantity weight)))
           :table (store-items store)
           :where (and (= u_item itemnum)
                       (= cartnum cartnum))
           :db db)

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


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

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