- 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
Actually worse than failure. Had the statement failed, it probably would have been noticed sooner.
Admin
Ah, the old "well we've checked absolute nothing but we're 1000% sure the problem isn't at our side - if you think it is, prove it!" response from suppliers. An annoyance I think we all know too well.
Once tried to tell a local council that one of their connections was down (which they should have already known as all their data was now going over one connection rather than being balanced over two!). They refused to believe us. Ended up with us, two ISPs, two MSPs and the national telecoms provided telling them before they'd entertain the idea of beginning to think about the possibility of looking into it.
Admin
Yep, good reason why writing your own SQL is never a good idea and like JavaScript it should be generated. I'm pretty sure who ever wrote that added the FROM clause out of habit.
Admin
In an ideal^Wsomewhat reasonable world, you would just threaten to sue them for gross neglect with a copy of the bill attached, and watch how quickly they resolve the issue, but of course, we're long past living in a somewhat reasonable world ...
Admin
I wonder if the dev who wrote that SQL statement was an Oracle user? I only think this because the FROM part of the statement is REQUIRED, and Oracle has a dual table for the sole purpose when you don't need data from a table.
Addendum 2025-09-23 08:58: I just remembered why they may have thought to use the FROM part: they might think that the last_insert_id() will look at the FROM statement and use the id from that table, and not just the last generated id from all tables.
Admin
"Everyone" apparently did not include the non-existent people who monitored database activity. How do you start a new application and not monitor database activity?
Admin
Please tell me that last_insert_id() is transaction specific.
It sounds like a race condition bug waiting to happen.
Hmm, first result on Googling suggests using an OUTPUT clause. Or is this a 'how to say you do not SQL without saying you do not SQL'.
Admin
From: https://dev.mysql.com/doc/refman/8.4/en/information-functions.html#function_last-insert-id
Admin
MySQL is a separate beast. Your answer is correct for SQL Server.
Admin
The equivalent gets "fun" in SQL Server... https://stackoverflow.com/questions/1920558/what-is-the-difference-between-scope-identity-identity-identity-and-ide
Admin
It's connection specific, you don't even need to start a transaction. MySQL was created with many quirks but this feature was right from the beginning. Failing to use it properly can only be explained by the fact that some kind of developers go through their entire career trying to learn the least they need to do their job.
Admin
I don't get it. Must be something specific to MySQL.
Admin
You must be new here.
Admin
. . . or hopelessly optimistic.
Admin
I can see how this happened: Internal non-IT customer buys product+service, but do not leave budget for internal IT to keep an eye on services. Or even tell internal IT of purchase.
Admin
I think it's more likely a case of "we ran it on our 10Gbps LAN with the two machines located right next to each other and didn't find any problems, so it must be at your end". There's at least one international standard that was developed that way, the company that paid for it apparently never tested it outside their own LAN so when it was deployed on the Internet where you have nasty things like, for example, packet loss, it was found not to work.
Admin
The third sentence, starting with the word "Someone", is TRWTF in this. In what universe does it make sense to run the database in one provider and the website in another?
Or have I missed something horribly obvious somewhere?
Admin
That was my thought as well. "Someone" should have just said NO.
Admin
I'm kinda surprised that the connection between the database and application has no form of compression. I suppose that's unlikely to be useful is most cases but it would be interesting.