GoTo Looping

  • Forty years ago I was in college and we heard about the evils of "gotos".

    We were only allowed to use a goto if we could justify why there was no better way to do it.

    After the first couple of justifications were shot down, we just stopped asking.

  • I must say, seeing Jeff Moden, Eric Russel, Joe Celko, people I have learned so much from, all chime in on the same thread... Well, it just brings a tear to my eye.

    Yes, trying to brown my nose. Have I succeeded? 🙂

    Good company.

    • This reply was modified 3 years, 5 months ago by  qbrt.
    • This reply was modified 3 years, 5 months ago by  qbrt.
  • jcelko212 32090 wrote:

    ... Then at Datamation magazine ran a gag article about the "come from" flow control structure as a replacement for the traditional "go to" flow control.

    Seriously! COMEFROM... Have never heard of it until now. Hilarious!

    COMEFROM - Wikipedia

     

  • Thank God there's no GOSUB in SQL.

    There's a school of thought that gets sniffy at overuse of if statements in OO languages.

    Such constructs feel like a vestigal organ like an appendix.

  • OMG, David Poole chimes in too. I can't stop crying. I feel so small.

     

    David.Poole wrote:

    Thank God there's no GOSUB in SQL.

    There's a school of thought that gets sniffy at overuse of if statements in OO languages.

    Such constructs feel like a vestigal organ like an appendix.

    Yes! YES!! Do not use "if" statements in OO 😀 !

    Sometimes it's not that simple to code away that "if" statement. I try my best, but get lazy.

  • David.Poole wrote:

    Thank God there's no GOSUB in SQL.

    There's a school of thought that gets sniffy at overuse of if statements in OO languages.

    Such constructs feel like a vestigal organ like an appendix.

    BWAAAA-HAAAAA-HAAAAAA!!! No... instead, we have folks that write sp_ and tbl_ and vw_ and fn_ and incremental rCTEs and "wonderful" built-ins like FORMAT and PIVOT, etc, etc.  And, yea... let's make our sp_'s 8 levels deep and have them call views of views and functions of functions.

     

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • qbrt wrote:

    I must say, seeing Jeff Modan, Eric Russel, Joe Celko, people I have learned so much from, all chime in on the same thread... Well, it just brings a tear to my eye.

    Yes, trying to brown my nose. Have I succeeded? 🙂

    Good company.

     

    Heh.... I had to laugh out loud at that!  Thank you for the fine feedback (although with only five letters in it, you could have spelled my name right :D) but, on the subject of browning your nose, remember that the only difference between a brown-noser and a s--t head is... depth perception. 😀 😀 😀

    I sure hope you take that as the joke it was intended to be. 😀

    Now... please excuse me... I have another thread that I have to GOTO. 😀

    And, being an ex-submarine sailor, I have to admit that GOSUB has a totally different meaning since then.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • The example presented in the article, executing a stored procedure within a loop for a set of input parameters, is one of those scenarios where looping is justly applied. Refactoring the procedure with a table valued input parameter would be ideal, but when running a one-off process or extending the functionality of a 3rd party application, it's best not to introduce risk by changing the functionality of something that works as intended elsewhere. I used to do more of this kind of stuff, before I started using PowerShell scripting.

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

  • Jeff Moden wrote:

    qbrt wrote:

    .. Thank you for the fine feedback (although with only five letters in it, you could have spelled my name right :D) ...

    Uhm .... I blame the keyboard. Had it replaced and lookie, the name is now spelled correctly 🙂

     

  • 😀

     

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 10 posts - 16 through 24 (of 24 total)

You must be logged in to reply to this topic. Login to reply