At 11:01 AM 02/22/2001 -0500, you wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
> > I haven't seen anything yet that talks explicitly about when
> > to use the Name attribute and when to use the Scope
> > attribute.  There have been a number of threads around
> > whether to single thread updates to a single table.
> >
> > For example, lets say that I read from a table in two
> > programs and write/delete from a third.  For this example,
> > lets say I want to single thread all writes.   To do this,
> > would you use  scope="application" type="readonly" to lock
> > the two read queries and scope="application" type="exclusive"
> > around the write or would replace the scope attribute in both
> > with something like name="databasename.tablename"?
>
>First of all...  Why in lord's name would you want to single thread
>your DB access?


   Fairly common example:

    You insert something in the database, and immediately need to access 
the ID of that new thing.  You want to single thread the insert and select, 
so the table doesn't change.

     Example:
       Table1   (a fairly static table)
       Table2   (A table that changes a lot)
       Table1Table2  (an intersection table, because their is a many to 
many relationship between table 1 and table 2)


     Insert into table2
     select the thing you just inserted into table2 (to get the ID)
     Inset into intersection table.


     You'll want to the first to SQL statements to be 
single-threaded.  There are SQL commands to do this, the commands commit 
and rollback come to mind.  I typically just use CFTRANSACTION in those 
cases, so I don't have the exact SQL syntax memorized.


     I think the remainder of this e-mail says it all about naming vs scope 
in a lock, though.  ;)


>In any case, if you did need to lock your DB for one particular
>table, then you would use a named lock with something like
>name="database.table" or whatever.
>
>Here's the skinny on when to use scope & when to use name for CFLOCK:
>
>If you're accessing a shared CF variable in the session, application,
>or server scope, then you should use a scoped lock of the appropriate
>scope.  You *shouldn't* access more than one scope within a single
>lock, tho I suspect you could access session in an application lock
>and application & session in a server lock without killing the
>server.  I would think that if automatic checking is enabled, it
>would probably disallow that activity.  I certainly wouldn't code
>anything to use it.
>
>For basically everything else, you use named locks.  When you're
>controlling access to anything that falls outside of the three CF
>shared scopes -- mostly "outside world" type of stuff -- scope
>doesn't work.
>
>Examples:
>You have a non-thread safe CFX tag.  You should use a lock that is
>the name of the tag around all accesses to it.
>Your DB example above is another valid example, tho I'm not sure why
>you'd want to do that.
>
>
>Hopefully that's at least a little clearer than mud...
>
>Best regards,
>Zac Bedell
>
>-----BEGIN PGP SIGNATURE-----
>Version: PGPfreeware 6.5.8 for non-commercial use <http://www.pgp.com>
>Comment: Please use PGP!
>
>iQA/AwUBOpU3x6vhLS1aWPxeEQJrsgCfR5nOE8vtxMj+PZLLim4GUIPI/mYAn2Hk
>iacc+HOazuS3mA+jxE63BbXa
>=E//I
>-----END PGP SIGNATURE-----
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to