- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Poor martin
Admin
It is always fun to look back at code and admonish the original writer to only later find out it was you.
Admin
Confession: I have, on at least one occasion, posted obscene, unsavory or otherwise inappropriate comments to this website.
Admin
This is why triggers should be WAY more complicated. Any idiot can write them these days, and that will just not do.
Come to think of it, the first thing I do when I notice a trigger on a table is say "Idiot!" and brace myself for the worst.
Admin
No wonder, if you want us to see our mistakes even before we do them.
Admin
I must admit I'm curious to know what the notification email said in lieu of deleting the reservation.
"Reservation successfully deleted."
Admin
I like how our thoughtful submitter made sure that Martin would receive all 1137 notification emails. Craftsmanship like that is just not appreciated anymore these days.
Admin
Admin
I thought I deleted this comment.
Admin
Wow, that's just precious!
But I am confused about one thing. The rows were getting deleted one at a time, right? But if it's an INSTEAD OF trigger, how were they getting deleted at all?
Addendum: I think the author should share some of his coffee with me. I spent a good 15 seconds trying to copy/paste the captcha and getting pissed off that it wasn't working. Brillant!
Admin
I am so disappointed. I kept waiting for the inevitable slip-up followed by:
(4926184 row(s) affected)
...and a head banging the desk.
Admin
This is the way he should have fixed it, in true WTF fashion:
Simple but effective, and just think of all those emails!
Admin
The INSTEAD OF had its own DELETE. At least that's what I've understood from the text.
Admin
I too, was waiting for this. As someone who made this mistake years ago, I'm ALWAYS waiting for this :)
Admin
Admin
Heh, Martin earned it after blocking every Thursday for everyone for a few years. You gotta teach him his lesson somehow.
Admin
Don't be rediculous. The emails were sent to "allusers"
Admin
I had this same situation one time. There, I fixed it by running the DELETE statement in a loop until SELECT returned 0 records.
I'm a bit of a Rock Star 'round these parts.
Admin
My name is Martin
I could have done the same
Admin
But the email got deleted before the mail was sent...
Admin
most frightening part:
Admin
TRWTF is deleting the reservation instead of marking it as "Canceled" or the equivalent.
Admin
Only four cups? That is noon for me (and yes that is probably not a good habit).
Admin
Admin
Who hasn't done this?
Admin
That's why I was waiting for it, too, I guess.
We have this utility that allows you to save rows into a table. While saving, you can use the option APPEND=YES. The default is, of course, APPEND=NO and so guess what happens if you save 20 rows without specifying APPEND=YES?
Admin
He should make sure the code sends 1337 emails each time to ensure its 1337ness.
Admin
So.... TRWTF is being able to write a delete statement against a production database. Surely the developer should not have access. What about testing and a change control process?
Admin
Admin
Eh. The address probably would have been marked as spam before it could do too much damage.
But then people wouldn't get email confirmations about their reservations being deleted! Oh, no!
Admin
I was reading the wikipedia's "List of countries by coffee consumption per capita" and noticed USA's 4.2kg (that's about 9 pounds) and thought to myself:
Only four kilos? That's April for us.
Admin
Yes, but from a database trigger?
Admin
In its defence, this application is merely an internal company admin tool.
Admin
FTFY
Admin
Admin
What is happening to this site????
The last 3 or 4 comments I have made have vanished without a trace (one made last night in this thread, and several in other threads over the last month or so), I do not think that i have been rude in any way....
What's the deal, I'm even a registered user for what it is worth.
Yours Yazeran
Plan: To go to Mars one day with a hammer.
PS I cant even see that I have made any posts when I go into stats on my user page....
Admin
You didn't send that unsubscribe request to all users, I hope?
Admin
Admin
People. Please stop replying to this to allusers. You're filling everybodys mailboxes and making the server slow down.
Admin
As I'm not sure whose job it is to address this matter, I am sending it to all users, in the hope that somebody out there is paying attention.
Admin
I hope Matthew recognizes the loss in productivity that he just produced.
Just think about it, a meeting reservation system that doesn't cancel reservations. How many meetings have been averted by this? How many meetings will the developers now have to attend?
Admin
Errr . how would that not trigger the same trigger again in a never-ending loop of love and unity ?
Admin
oops .. i meant pull the trigger ... or fire was it ? ^^
Captcha: eros ... pull the trigger, definitely.
Admin
I have a 2 dumb questions.
Let us assume that the specification for the system is "The client has to be notified when any change happens to their reservation" This includes the "Your reservation for resource Room 101 for Monday 5 September 2011 has been deleted" message.
Why is getting that email sent at the point in time that the delete occurs a bad thing?
What else would you do, have something polling to go "Is anything missing now? How about now? Now?" How else would you be able to act on a direct DELETE statement.
Admin
Admin
Assuming SQL Server, triggers can be configured to be non-recursive and have varying levels of permitted nesting.
No sane person would enable recursive triggers in their database.
Admin
Not coding till 3 am should fix that.
Admin
To answer your dumb questions
It's not, and nobody that Im aware of said it was so.
Sending emails (outside of perhaps server monitoring) is not the job of SQL Server. This is application logic and should happen in the application. ie
User Chooses to delete a block of meetings
a) begin atomic operation b) Delete records from database (better: Mark as cancelled in database) c) Compile 1 email (FFS!) with a list of the deleted meetings and send to originator of meeting / requestor of delete. 3) Sit back happy that you have a sensible solution.
Admin
STORY OF THE ORIGINAL NON-DELETING DELETE:
IBM executive to programmer: And don't forget that there must also be a way to delete files from the disk. Remember: we have top-secret data that we don't want to keep on the drive for longer than necessary.
Programmer: OK, I found a very ressource-efficient way to delete files.
Executive: Great! Here's your bonus.
Programmer: Nevermind. Can I just take some of the old disks back home instead?
Executive: Sure thing (sacks programmer's bonus)
Admin
No problem here: this is preferred way to prevet colleagues from damaging database. Privilejes not to be extending possibly letting randumb operater annialate usefull meeting property of company.
Please be not to be damnaging database in the future.