Thanks Dana and Chip. That did it!
--On Wednesday, July 12, 2000 4:25 PM -0700 Dana Powers
<[EMAIL PROTECTED]> wrote:
> You'll need to use $sth = $dbh->prepare(...); and $sth->execute();
> Then ($lock) = $sth->fetchrow_array(); and $sth->finish();
> $dbh->do assumes that you are inserting or updating and so you dont
> expect any results back. A GET_LOCK does not work like that, as you have
> noted, so you will need to treat it like a select statement. I use these
> locks to simulate a row-level locking system and it works quite well.
> Dana
>
>
> On Wed, 12 Jul 2000, Rob Tanner wrote:
>> I want to use advisory locks in MySQL. The functuion is GET_LOCK(), and
>> the way it should be used is SELECT GET_LOCK(). It return 1 is
>> successful, 0 if timed out, and undef on error. The sequence:
>>
>> my $db_lock = 'GET_LOCK("mylock", 5)';
>> my $result = $dbh->do($db_lock);
>>
>> returns "1" regardless of whether the lock was obtained. According to
>> the cheetah book (Programming the Perl DBI), page 120/1, that's
>> correct. The $dbh->do statement only returns "0" on an error.
>>
>> How do I execute the MySQL GET_LOCK function and get back the real
>> result (0 or 1). Always getting back a 1 as if I got the lock, whether
>> I did or not, kind of defeats the purpose.
>>
>> What is the work-around?
>>
>> Thanks,
>> Rob
>>
>> _ _ _ _ _ _ _ _ _ _
>> /\_\_\_\_\ /\_\ /\_\_\_\_\_\
>> /\/_/_/_/_/ /\/_/ \/_/_/_/_/_/ QUIDQUID LATINE DICTUM SIT,
>> /\/_/__\/_/ __ /\/_/ /\/_/ PROFUNDUM VIDITUR
>> /\/_/_/_/_/ /\_\ /\/_/ /\/_/
>> /\/_/ \/_/ /\/_/_/\/_/ /\/_/ (Whatever is said in Latin
>> \/_/ \/_/ \/_/_/_/_/ \/_/ appears profound)
>>
>> Rob Tanner
>> McMinnville, Oregon
>> [EMAIL PROTECTED]
_ _ _ _ _ _ _ _ _ _
/\_\_\_\_\ /\_\ /\_\_\_\_\_\
/\/_/_/_/_/ /\/_/ \/_/_/_/_/_/ QUIDQUID LATINE DICTUM SIT,
/\/_/__\/_/ __ /\/_/ /\/_/ PROFUNDUM VIDITUR
/\/_/_/_/_/ /\_\ /\/_/ /\/_/
/\/_/ \/_/ /\/_/_/\/_/ /\/_/ (Whatever is said in Latin
\/_/ \/_/ \/_/_/_/_/ \/_/ appears profound)
Rob Tanner
McMinnville, Oregon
[EMAIL PROTECTED]