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

lock-tables

Arguments: &key read write db showsql

This function generates and executes an sql "lock tables" statement. The read and write arguments describe which tables are to be locked for reading and writing respectively.

The db, which defaults to the value of *mysql*, must be a mysql object such as returned by connect.

The values of the read and write arguments can be either:

  1. a string naming a single table
  2. a list (tablename :as alias) where tablename and alias are strings.
  3. a list of items from 1 and 2.

You can see the sql generated by specifying t as the value of showsql.

cl-user(13): (lock-tables :read "aaa" 
                          :write '("bigtab" ("ccc" :as "c")) 
                          :showsql t)
sql: "lock tables  aaa read ,  bigtab write ,  ccc as c write"
nil
cl-user(14): 

If the code that uses the tables while they are locked uses a table alias then you must lock the tables under that alias or MySQL will complain. So if you have this code:

(sql "select f.item, b.item  from foo f, bar b")

then you must have locked the table "foo" under the alias "f" and the table "bar" under the alias "b". You may end up specifying that the same table be locked multiple times under different aliases and under no alias:

(lock-tables :read '("foo" ("foo" :as "f") ("foo" :as "ff")))

After locking tables you'll likely want to use the with-locked-tables around the code that processes the locked tables. This ensures that the locks get released when control leaves the with-locked-tables body.

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