FunctionPackage: dbi.mysqlToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 10.1
Unrevised from 10.0 to 10.1.
10.0 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-2022, Franz Inc. Lafayette, CA., USA. All rights reserved.
This page was not revised from the 10.0 page.
Created 2019.8.20.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 10.1
Unrevised from 10.0 to 10.1.
10.0 version