I'm trying to simulate named SEQUENCES (a la Oracle or Postgres) in MySQL
(InnoDB).  I have a table sequences with attributes name (varchar) and value
(integer).  Conceptually, I'd like to do this

my $seq_name = 'foo';
my $db = $seq->db;

$db->begin_work;
$seq->load( name => $seq_name );
my $value = $seq->value; 
$seq->value($value + 1);
$seq->save;
$db->commit;

(modulo error handling, etc.) 

However, I'd like to actually get an exclusive lock on the record at load
time.  I'd usually do a "SELECT ... FOR UPDATE" to do this in MySQL.  Can I
get that behavior using just the load method above?  I can use a
make_manager_method_from_sql() call with a "SELECT ... FOR UPDATE" but
wondered if I can get this behavior from the object methods alone?  I'm
basically looking for a way to control the concurrency from within the load
method.

-- Jeff Horn



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to