[forwarded submission from a non-member address -- rjk]


From: Dave Turner <[EMAIL PROTECTED]>
Date: 27 Mar 2002 19:59:21 -0500
Subject: Re: [Boston.pm] DBI weirdness
To: Matthew Brooks <[EMAIL PROTECTED]>
Cc: Joel Gwynn <[EMAIL PROTECTED]>, [EMAIL PROTECTED]

This is a non-answer to the question. It could well be that in his
particular case, this doesn't matter.  Or, maybe it's too expensive. And
checking for existence before doing a delete is totally pointless, as
delete returns the number of rows deleted, and a delete which operates
on no records is (excluding bizarre triggers) a no-op.

Crashing is not acceptable in the presense of perfectly fine SQL.

Anyway, the update statement says something more like "wash each of my
cars", which is a no-op in the case of no cars.

On Wed, 2002-03-27 at 18:29, Matthew Brooks wrote:
> 
> MessageChecking for the existence of a particular record in a database
> before performing an UPDATE/DELETE on it is just good programming
> practice. An UPDATE/DELETE by definition, and in comparison to an INSERT,
> assumes that the record already exists.
> 
> Think of it this way... If someone asked you to take their car over to
> the car wash for them, but they didn't actually own a car; how likely is
> it that you would be able to get their car washed?
> 
> Matthew
> 
> 
>   ----- Original Message ----- 
>   From: Joel Gwynn 
>   To: [EMAIL PROTECTED] 
>   Sent: Wednesday, March 27, 2002 12:27 PM
>   Subject: [Boston.pm] DBI weirdness
> 
> 
>   This is something bothersome that just started happening, or I just
>   began noticing.  If I try to update or delete a record, like so:
>   "update addresses set first_name='Joel' where user_id=1", and there is
>   no record matching user_id=1, my script hangs.  If the record exists,
>   everything is fine.
> 
>   I've been working around this by checking for the existence of a record
>   before deletion/updating, but it doesn't seem right that I should need
>   to do this.  What could be the problem?
> 
>   I'm using DBI 1.14 on WindowsNT with SQL Server.
-- 
-Dave Turner                                Stalk Me: 617 441 0668
"Somebody would have done it, if we hadn't done it." 
    -Laurence Canter, of Canter and Siegel, spammer.
"And where have I heard that before?" 
    -Mr. Meany (a demon), _Meadow Of The Damned_, by Scott McCloud

Reply via email to