1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
<!-- manual page source format generated by PolyglotMan v3.0.4, -->
<!-- available via anonymous ftp from ftp.cs.berkeley.edu:/ucb/people/phelps/tcltk/rman.tar.Z -->
<HTML>
<HEAD>
<TITLE>FETCH(SQL) manual page</TITLE>
</HEAD>
<BODY>
<A HREF="sql.html">SQL Reference Contents</A>
<H2><A NAME="sect0" HREF="#toc0">NAME </A></H2>
lock - exclusive lock a table
<H2><A NAME="sect1" HREF="#toc1">SYNOPSIS </A></H2>
<B>lock </B> classname <BR>
<H2><A NAME="sect2" HREF="#toc2">DESCRIPTION
</A></H2>
<B>lock</B> exclusive locks a table inside a transaction. The classic use for
this is the case where you want to <B>select </B> some data, then update it inside
a transaction. If you don't exclusive lock the table before the <B>select
</B>, some other user may also read the selected data, and try and do their
own <B>update </B>, causing a deadlock while you both wait for the other to release
the <B>select </B>-induced shared lock so you can get an exclusive lock to do
the <B>update. </B> <P>
Another example of deadlock is where one user locks one table,
and another user locks a second table. While both keep their existing
locks, the first user tries to lock the second user's table, and the second
user tries to lock the first user's table. Both users deadlock waiting for
the tables to become available. The only solution to this is for both
users to lock tables in the same order, so user's lock aquisitions and
requests to not form a deadlock.
<H2><A NAME="sect3" HREF="#toc3">EXAMPLES </A></H2>
-- <BR>
-- Proper locking to prevent
deadlock <BR>
-- <BR>
begin work; <BR>
lock mytable; <BR>
select * from mytable; <BR>
update
mytable set (x = 100); <BR>
end work; <BR>
<H2><A NAME="sect4" HREF="#toc4">SEE ALSO </A></H2>
<A HREF="begin.l.html">begin(l)</A>
, <A HREF="end.l.html">end(l)</A>
, <A HREF="select.l.html">select(l)</A>
.
<P>
<HR><P>
<A NAME="toc"><B>Table of Contents</B></A><P>
<UL>
<LI><A NAME="toc0" HREF="#sect0">NAME</A></LI>
<LI><A NAME="toc1" HREF="#sect1">SYNOPSIS</A></LI>
<LI><A NAME="toc2" HREF="#sect2">DESCRIPTION</A></LI>
<LI><A NAME="toc3" HREF="#sect3">EXAMPLES</A></LI>
<LI><A NAME="toc4" HREF="#sect4">SEE ALSO</A></LI>
</UL>
</BODY></HTML>
|