[Pdx-pm] DBI/DBD::Pg SELECT ... FOR UPDATE
Selena Deckelmann
sdeckelmann at chrisking.com
Tue Jul 17 15:48:54 PDT 2007
On Jul 17, 2007, at 2:58 PM, Roderick A. Anderson wrote:
> How does/ or does DBI handle row level locks that Postgresql (and I
> think Oracle) provides. Do they apply to the database handle ($dbh)?
>
> So if,
>
> ###
> my $sth = $dbh->prepare(q{SELECT the, info FROM thetable WHERE the
> = 'R'
> FOR UPDATE });
Not a perl solution -- but you could add a column or a table that
tracks which rows that you are currently processing.
Maybe I shouldn't admit this (don't hurt me, Randal!) - but I have a
printing system for barcode printers that could get accessed by a
variety of people at the same time. I change the status inside a
transaction to reference the process ID (and the print logfiles have
the PIDs in them). That way, when there's a failure, I can track link
it to a specific file that was printed (all the files have the PID
embedded in them). Also, if two jobs get called simultaneously,
there's no double-printing.
This type of thing gets you out of the business of policing your cron
jobs.
-selena
More information about the Pdx-pm-list
mailing list