| List: | General Discussion | « Previous MessageNext Message » | |
| From: | Paul DuBois | Date: | August 24 1999 9:24pm |
| Subject: | RE: update? insert? Perl script | ||
| View as plain text | |||
At 4:55 PM -0400 8/24/99, Dan Ray wrote: >Paul wrote: >> if (defined ($yes)) # row exists >> { >> update >> } >> else # row does not exist >> { >> insert >> } > >I believe I may have stumbed across a better strategy than this. Anybody got >any reason this wouldn't work? > >update >get rows affected >if (! rows affected) { > insert >} > >In otherwords, just updating blindly, checking for effects, and inserting >based on that. It's one fewer queries, certainly. Any downside to this? If you happen to update to the same value, the row won't be considered "affected" by MySQL and the row count will be zero. Then you'll insert another row. -- Paul DuBois, paul@stripped
| Thread | ||
|---|---|---|
| • update? insert? Perl script | gl3 | 24 Aug |
| • Re: update? insert? Perl script | Jeff Beard | 24 Aug |
| • Re: update? insert? Perl script | Paul DuBois | 24 Aug |
| • RE: update? insert? Perl script | Dan Ray | 24 Aug |
| • Re: update? insert? Perl script | Thimble Smith | 24 Aug |
| • RE: update? insert? Perl script | gl3 | 24 Aug |
| • Re: update? insert? Perl script | Scott Hess | 24 Aug |
| • RE: update? insert? Perl script | Paul DuBois | 24 Aug |
| • RE: update? insert? Perl script | Jay Miller | 24 Aug |
| • RE: update? insert? Perl script | Michael Widenius | 29 Aug |
| • RE: update? insert? Perl script | Dan Ray | 25 Aug |
| • Re: update? insert? Perl script | B.W. McAdams | 24 Aug |
