• (nodebb)

    What is "WITH UR" even supposed to do? What SQL dialect is this? I'm genuinely curious.

  • Strongarm (unregistered) in reply to Mr. TA

    DB2 Uncommitted Read Allows it to read without locking the table.

  • (nodebb)

    Maybe it produces output in Assyrian?

  • (nodebb)

    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.

  • (nodebb) in reply to Mr. TA

    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.

  • Pabz (unregistered)

    Which is worse - programming by Google, Stack Overflow or ChatGPT?

  • Foo AKA Fooo (unregistered) in reply to Pabz

    Either ChatGPT or TDWTF, it's close.

  • Foo AKA Fooo (unregistered) in reply to MaxiTB

    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 ...)

  • (nodebb) in reply to Pabz

    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.

  • Darren (unregistered) in reply to Pabz

    A truly 'gifted' programmer will use all three!

  • (nodebb) in reply to thosrtanner

    Babylonian laughs at your Assyrian syntax! The code of Hammurabi is clearly superior.

  • (nodebb) in reply to MaxiTB

    endless scrollers eliminated the need for it

    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.

  • (nodebb) in reply to Darren

    A truly 'gifted' programmer will use all three!

    you forgot the rest of the sentence: "... to know definitively what NOT to do."

  • Zatapatique (unregistered) in reply to MaxiTB

    Oracle also has a WITH clause for subquery's: https://oracle-base.com/articles/misc/with-clause.

  • (nodebb)

    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/

  • Richard Brantley (unregistered) in reply to MaxiTB

    "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.

  • know (unregistered)

    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?

  • Conradus (unregistered) in reply to Mr. TA

    "What is "WITH UR" even supposed to do? What SQL dialect is this? I'm genuinely curious."

    It's short for "WITH UR MOM".

  • Industrial Automation Engineer (unregistered) in reply to Pabz

    It's programming by "The Daily WTF"

  • Argle (unregistered)

    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.

  • (nodebb) in reply to Argle

    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...

  • JJ (unregistered) in reply to MaxiTB

    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...

  • Fizzlecist (unregistered)

    "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

  • xtal256 (unregistered)

    "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.

  • (nodebb) in reply to Foo AKA Fooo

    I'm with you, can't stand this endless scrolling nonsense.

    Give me good ol' pagination any day of the week.

  • Aitkiar (unregistered)

    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.

  • (nodebb) in reply to MaxiTB

    Obviously .net evolves greatly so a 5 year old answer might be completely wrong, so it's important to consider the date as well.

    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.

  • (nodebb) in reply to MaxiTB

    Obviously .net evolves greatly so a 5 year old answer might be completely wrong, so it's important to consider the date as well.

    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.

  • (nodebb)

    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.

  • (nodebb) in reply to R3D3

    This comment closed as duplicate.

  • Erin (unregistered) in reply to MaxiTB

    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.

  • Duke of New York (unregistered)

    If I’m not mistaken, this code would also leak a connection on every call?

Leave a comment on “A Matter of Understanding”

Log In or post as a guest

Replying to comment #:

« Return to Article