- 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
What is "WITH UR" even supposed to do? What SQL dialect is this? I'm genuinely curious.
Admin
DB2 Uncommitted Read Allows it to read without locking the table.
Admin
Maybe it produces output in Assyrian?
Admin
Ironically using SQL COUNT itself is often a code smell. Yes, in the past it was required for pagination previews (which always was an unreliable estimate anyway) but UX has evolved since then and endless scrollers eliminated the need for it. Sure, there are use cases where you have to aggregate data in a certain way, but those are highly limited. So seeing this method I wonder if there are bigger architectural issues at play in general.
Admin
Isolation level, uncommitted read. I think it's an IBM thing, I vaguely remember it seeing it working for a client using DB2 but that was ages ago, don't take my word for it.
Admin
Which is worse - programming by Google, Stack Overflow or ChatGPT?
Admin
Either ChatGPT or TDWTF, it's close.
Admin
Highly limited? I think you severely misunderestimate the diversity of programming jobs. My code base has a quite a few SELECT COUNT instances, and only a few of them are for pagination (which, BTW, I as a user still prefer to endless scrolling, mostly, well, because you don't have to scroll endlessly ...)
Admin
Stack Overflow often has great answers (at least for .net) but it's often not the most upvoted one; always check out the second answer as well. Obviously .net evolves greatly so a 5 year old answer might be completely wrong, so it's important to consider the date as well.
However that should be a starting point, the answers are the now where the research starts if they hold up ground. A web search engine is useful in that regard but be prepared to encounter a lot of garbage.
Finally ChatGPT is completely useless if you are not already an expert in the topic anyway. It confidently recommends anti-patterns, not thread-safe code (race conditions) and outdated solutions with known security vulnerabilities. So for experts it's pointless to use beyond having fun with a silly toy and for non-experts it can be outright dangerous.
Admin
A truly 'gifted' programmer will use all three!
Admin
Babylonian laughs at your Assyrian syntax! The code of Hammurabi is clearly superior.
Admin
Get thee behind me endless scrolling.
Endless scrolling is horrible for anything except smallish result sets. I suggest we all move to pagination to eliminate the need for endless scrolling.
Admin
you forgot the rest of the sentence: "... to know definitively what NOT to do."
Admin
Oracle also has a WITH clause for subquery's: https://oracle-base.com/articles/misc/with-clause.
Admin
For anyone interested in the UX considerations around endless scrolling, check out this summary from the Nielsen Norman Group: https://www.nngroup.com/articles/infinite-scrolling-tips/
Admin
"However that should be a starting point, the answers are the now where the research starts if they hold up ground."
I am reminded of my English teachers who said, "write it in your own words." I wish more people took things like Stack Overflow as a learning opportunity and not a coding familiar.
Admin
By the way, what is count?? It is incremenred at each reply row nut I do not see it declared or initialized. Perhaps, it is a global variable counting all reply rows received throughout the run?
Admin
"What is "WITH UR" even supposed to do? What SQL dialect is this? I'm genuinely curious."
It's short for "WITH UR MOM".
Admin
It's programming by "The Daily WTF"
Admin
Me reading stack overflow: "Didn't anyone bother to read this person's question? Spew based on keywords isn't an answer."
Me with ChatGPT:
ChatGPT: Here is a totally bogus solution to your question that looks like it might work.
Me: That's wrong and will throw an exception.
ChatGPT: I'm sorry about that. Here's an alleged correction.
Me: You're pretty worthless.
ChatGPT: I humbly apologize and offer yet another bad solution as penance.
Admin
Yeah, well the problems with any LLM trained using code that's freely available on the Internet are encapsulated neatly in Sturgeon's Revelation: "ninety-percent of everything is crud".
And in context, the particular slice of "everything" that's interesting is "software". Not just "code that's freely available on the Internet", but all of it. So we train the LLM on code that's 90% crud, and we expect the LLM to somehow generate actual good code...
Admin
I wish I could get this across to my co-worker who I'm fairly sure just puts everything they don't understand into ChatGPT now as a matter of course.
Error message too long to bother reading? There's no attempt made to understand it, it just gets copy-and-pasted into ChatGPT!
And if the ChatGPT output is too complicated to understand at a glance, the response is pasted into our Teams group chat to make it everyone else's problem instead. The one thing that must be avoided is actually thinking about a problem in order to understand it!
Thank you for letting me vent...
Admin
"The query contains a WITH clause, but it's in the wrong spot". If it's DB2 SQL (which it looks like) then it's in the right spot
Admin
"Easy Reader Version: If you don't understand the code, don't commit it"
I initially read that as "... don't vomit it", which somehow seems even more appropriate.
Admin
I'm with you, can't stand this endless scrolling nonsense.
Give me good ol' pagination any day of the week.
Admin
WITH UR is a DB2 idiom that means, give me every record even those that are on an uncommited transaction and don't lock.
It was wildly use on heavy concurrrent cobol systems to avoid locking. It was consider less of a problem getting results that could be rollbakced than getting your query locked pending another transaction.
Admin
One of the main reasons I usually ask questions on Reddit now. On Stack Overflow chances are that any new question will be closed as duplicate, referencing a ln older question, that no longer is accurate, yet it doesn't encourage updating those old answers either.
I sometimes still post solutions though, as a way to write them up with markdown and then capture the page in Evernote.
Except that I should soon migrate away from Evernote as the get increasingly desperate to push people into the subscription without offering a low level tier worth how little I actually use it these days, while risking that the free tier becomes entirely useless.
Admin
One of the main reasons I usually ask questions on Reddit now. On Stack Overflow chances are that any new question will be closed as duplicate, referencing a ln older question, that no longer is accurate, yet it doesn't encourage updating those old answers either.
I sometimes still post solutions though, as a way to write them up with markdown and then capture the page in Evernote.
Except that I should soon migrate away from Evernote as the get increasingly desperate to push people into the subscription without offering a low level tier worth how little I actually use it these days, while risking that the free tier becomes entirely useless.
Admin
The
WITH
clause referring to named sub-queries AKA common table expressions was added to the standard in 1999. Of course support by all the major DBs took awhile to solidify, but they're 26 years old now, so not bleeding edge stuff.I never worked with DB2 but interesting that they chose to use the same keyword for a totally different concept. IIRC, SQL was a bit of a graft onto DB2's query system that predated the rise of SQL.
Admin
This comment closed as duplicate.
Admin
SO has good answers for most things. The problem is that alongside every good answer there's 8 wrong answers and 37 comments complaining about syntax or design patterns that the asker may have zero control over.
As with much of the internet, finding the "good" answer among the sea of crap is the real challenge, especially when the asker is, by definition, unaware of what the good answer should be and maybe doesn't even have a good idea of what it should look like in broad terms.
Admin
If I’m not mistaken, this code would also leak a connection on every call?