• Jay (unregistered) in reply to Brian
    Brian:
    Zapp Brannigan:
    Note: I submit all of my comments with grammar and spell check options disabled.

    Is it a form of recursion when someone points out a grammar or spelling error in a post when their replying post also has a spelling or grammar error?

    I don't know. You tell me. Someone is singular, thus the pronoun referring to someone should be singular as well, such as his, her, or his/her.

    But if he had written "when someone points out a grammar or spelling error in a post when he is replying ...", the server would have thrown a PoliticalIncorrectnessException.

  • Calli Arcale (unregistered) in reply to VeryProfessional
    VeryProfessional:
    If you have a hammer, everything looks like a nail...

    I prefer the way Red Green illustrated this.

    In his workshop, he displayed a wooden board with several things stuck into it -- a few nails, but mostly various types of screws. He was discussing how important it is to select the right tool for the job, pointing out that some screws are Philips, some are flathead, some are hex.... Then he pulled out a large hammer and pounded every single one of them down into the board.

    "Remember: any tool can be the right tool."

    I am increasingly of the opinion that Red Green's design and implementation philosophies actually permeated the brain of his geeky nephew, Harold, who then went on to become a world-famous software engineer. It's the only possible explanation for the proliferation of this sort of code.

  • Elvis (unregistered) in reply to SQL Guy
    SQL Guy:
    Awful, just awful!

    He didn't even use a stored procedure!

    LMAO!

  • (cs)

    Toletarting! That's great!

    Along with "Termination Date to early!". If you read that phrase the way "to" is supposed to be read in this situation, which is, without any emphasis and spoken quickly, you'll realize that it's wrong.

    Kinda like when I read "we don't want to loose track of ..." and of course, mentally I pronounce "loose" the way it is correctly pronounced (lus with a long u), which is different than "lose" (luz).

  • Ken B (unregistered) in reply to DOA
    DOA:
    Can't wait to see how he validates email addresses.
    SELECT Name from SpammerCDListCollection WHERE eMail = ?

    Captcha: appellatio. What Adam and Eve did that got them kicked out of Eden.

  • Ken B (unregistered) in reply to Zapp Brannigan
    Zapp Brannigan:
    Is it a form of recursion when someone points out a grammar or spelling error in a post when their replying post also has a spelling or grammar error?
    It's called "Skitt's Law".
  • Benjie (unregistered) in reply to adiener

    Require that all SQL code be done through functions and have a proper object wrapper. Should make things interesting.

  • (cs)

    Guys, I've figured out the rule for the "toletarting" thing: Where "r" found in character stream, grab the next character, then insert "t" followed by that character before the "r".

    So here's the fixed version: "Of coutsre, since outr management is non-technical, theter's vetyr little any of us can do aside ftorm just toletarting the code. Aftetr all, his code turns about the same as outsr... and that's all that mattetsr, tirght?"

  • BlindedByTheCode (unregistered)

    The goggles, they do nothing!

    Captcha: populus

    The choice of SQL to do date validation is frowned upon by the populus.

  • dignissim (unregistered) in reply to methinks
    methinks:
    SenTree:
    tim:
    throw new TooManyLayersOfPedantryException 
    ..........................................^
    Error at line 1 col 43: ";" expected
    FTFY

    No.

    Error at line 1 col 43: "(" expected
    Since this entire tartgument took place in a web forum, I do believe the language in question is javascript.

    Making the omission of a statement-terminating semi-colon or even .ctor parentheses perfectly valid, albeit counter-indicated.

    <internet/> ...even if you win, you're still /b/tarded

  • silver lining (unregistered) in reply to Ouch!
    Ouch!:
    Jack:
    if(!allowed.equalsIgnoreCase("allowed")){ throw new Exception("Termination Date to early!"); }

    Looks like using proper grammer was something he did NOT overdo

    To pick a nit: It's a matter of spelling, not grammar. And you've slipped in a typo, too.

    Hmmm...delicious irony

  • Gerb (unregistered)

    Some would say performance also matters... and maintenance. But then you'd need management with at least a global understanding of technical matters. Maybe they need to check out ISO 9126?

  • (cs)

    Stupid designs like this make me angry.

    I mean, it's so obvious that stmt.close() should be in a finally block...

  • grahamsw (unregistered) in reply to VeryProfessional

    If all you have is a hammer everything looks like a baby seal.

  • pueblonative (unregistered) in reply to Ouch!

    No. "to" is not misspelled. It's incorrectly used when "too" is what the author meant.

  • J (unregistered)

    After reading this submission, and all the related comments, I can only really add one thought:

    A tart sounds delicious!

  • J (unregistered) in reply to grahamsw
    grahamsw:
    If all you have is a club everything looks like a baby seal.
  • J (unregistered) in reply to J
    grahamsw:
    If all you have is a club everything looks like a baby seal.

    FTFY

  • (cs) in reply to Benjie
    Benjie:
    Require that all SQL code be done through functions and have a proper object wrapper. Should make things interesting.

    Just what the world needs. More useless layers. Russian doll coding is worse than spaghetti coding.

  • (cs) in reply to Calli Arcale
    Calli Arcale:
    VeryProfessional:
    If you have a hammer, everything looks like a nail...

    I prefer the way Red Green illustrated this.

    In his workshop, he displayed a wooden board with several things stuck into it -- a few nails, but mostly various types of screws. He was discussing how important it is to select the right tool for the job, pointing out that some screws are Philips, some are flathead, some are hex.... Then he pulled out a large hammer and pounded every single one of them down into the board.

    "Remember: any tool can be the right tool."

    SQL is seductive for dates if you already have a database connection open. Consider trying to figure out the date of 6 months ago. With SQL, its
    SELECT curdate() - INTERVAL 6 month;

    That's really a lot less painful than most of the date libraries available. If you have a cool library available though, best use that.

  • (cs) in reply to pueblonative
    pueblonative:
    No. "to" is not misspelled. It's incorrectly used when "too" is what the author meant.
    Okay, then it's a matter of semantics. Still isn't a grammatical error (if we allow exception messages which aren't complete sentences - otherwise writing 'too' wouldn't save it either).
  • mr_smith (unregistered)

    This looks like Java. The Date/Time piece of Java is horrid and date comparison is not trivial if you want to ignore the time. Generally what you would do is write a method that handles comparison and then use that method instead (or go find a better Java Date library). However, I've been tempted to do garbage like this at times.

    Try finding the difference in days between two dates. It isn't exactly a built in method in Java.

    I know this is no excuse.

  • (cs)

    This code might run the same as yours, except with the added overhead to connect to the db each time...?

  • (cs)

    I had a good laugh until it dawned on me that some of the older code I inherited should have similar crap. I mean it was coded by feces throwing monkeys, so I went searching:

    //Used multiple times to retrieve current date

    Select Now()

    // Classic Mathematics .. I’m guessing adding numbers in Perl is too complicated

    Select SUM($acc_val + $acc_left)

    I wish I was making this crap up....but these are the same guys that have a method that queries the same table 8 times to retrieve 8 different columns....OH THE PAIN

  • Robert (unregistered)

    Your kidding, right??? I mean who cares!!!! People REALLY care about crap like this?!?!?!?! Get a life.......

  • (cs) in reply to jjrun1
    jjrun1:
    This code might run the same as yours, except with the added overhead to connect to the db each time...?

    Really depends if you are already connected to the db and running other queries, or if the code run is run a few times a day.

  • Markus (unregistered)

    Its tottally indistegible kode und enritely untoletartable forewort. Schame.

  • (cs) in reply to JustLee
    JustLee:
    I wish I was making this crap up....but these are the same guys that have a method that queries the same table 8 times to retrieve 8 different columns....OH THE PAIN

    You have got to be f*cking kidding me!

  • Laughing Jack (unregistered) in reply to SQL Guy
    SQL Guy:
    Awful, just awful!

    He didn't even use a stored procedure!

    Or an object layer!
  • (cs) in reply to tdittmar
    tdittmar:
    SenTree:
    tim:
    throw new TooManyLayersOfPedantryException 
    ..........................................^
    Error at line 1 col 43: ";" expected
    
    FTFY

    Actually I had a good laugh at the first version, as it was formatted like

    throw new TooManyLayersOfPedantryException 
    ..........................^
    Error at line 1 col 43: ";" expected
    

    Then I started to wonder how you can have more than one layer of pee...

    For me it showed up pointing to right after the 's' in layers, implying it should read

    throw new TooManyLayers;OfPedantryException

    that made me wonder what the heck they were on about.

  • (cs)

    Well I think there is a nice artistic balance in having Spelling/Grammertical errors in an absoluting and pedantic piece of SQL code.

    A mix of Logic and Anti-Logic is always an entertaining way of checking code. ;-P

  • Cappy (unregistered)

    The TOLETART function isn't available in DB2 until V10.1,

  • NailHammer (unregistered)

    When you only have nails, everything (else) looks like a hammer.

  • oheso (unregistered) in reply to coyo
    coyo:
    SQL is seductive for dates

    You have got to get out more!

  • (cs) in reply to adiener
    adiener:
    bool FirstIsLowerOrEqual (int i1, int i2) { std::string test = "if [ $i1 -le $i2 ]; then echo first; else echo second; fi"; std::ostringstream cmd; cmd << "i1=" << i1 << "; i2=" << i2 << ";" + test; return ! system ("test `ssh some.where /bin/sh -c '" + cmd.str() + "` == first"); }
    Nice, but you have an unterminated single quote in there.
    Thanks for pointing it out! I could not test it before posting because here at work we don't use a Unix operating system ... unfortunately :-(
  • JM (unregistered) in reply to Robert

    Certain coworker, is that you?

  • (cs)

    We used to have a colleague who liked to do things in Oracle. For example, encryption.

    Now, the question arises what use encryption is when you first send an unencrypted text to the database server in order to retrieve the encrypted text, but let's ignore that for the moment.

    So, at some point I was tasked with rewriting this in Java. Did you know what you can do some sort of Double DES in Oracle? So not DES or 3DES, but something in between using a 128-bit key.

    That was quite an interesting exercise.

  • Barn (unregistered) in reply to silver lining

    No, You spell it Hmm (one less m) </joke>

  • Barn (unregistered) in reply to silver lining
    silver lining:
    Ouch!:
    Jack:
    if(!allowed.equalsIgnoreCase("allowed")){ throw new Exception("Termination Date to early!"); }

    Looks like using proper grammer was something he did NOT overdo

    To pick a nit: It's a matter of spelling, not grammar. And you've slipped in a typo, too.

    Hmmm...delicious irony

    No, You spell it Hmm (one less m) </joke>

  • (cs) in reply to Oxin
    Oxin:
    toletarting?

    Cue the IrishGirl jokes in 3...2...1...

  • JM (unregistered)

    What's that? Java? JDBC?

    This guy's a piker. I know a guy who writes the entire application in PL/SQL. He regards Java as a sign of weakness.

    (He is actually a good friend and I've worked with him several times, but I've often had to ask him not to do his stuff as it tends to be hard for mere mortals to maintain.)

  • Level 2 (unregistered)

    Could be worse. At least he uses bind variables, so no SQL injection problems.

  • tragomaskhalos (unregistered)

    Hey, I hate Java's godawful date handling classes as much as the next man, but even so ...

  • Henning Makholm (unregistered) in reply to Severity One
    Severity One:
    So, at some point I was tasked with rewriting this in Java. Did you know what you can do some sort of Double DES in Oracle? So not DES or 3DES, but something in between using a 128-bit key.
    Are you sure it wasn't just the common two-key keying mode of Triple DES, in which one of two 56/64-bit keys is used twice?

    Actual "double DES" is hardly ever used at all -- it is not appreciably stronger than single DES due to the meet-in-the-middle attack construction.

  • caradietra (unregistered)

    Exception? C'mon, finish what you started, go back and do a RAISERROR.

  • (cs)

    It could be worse.

    He could decide to to everything in Visual Basic!!

    *on a wooden table, with XML, for Paula...

  • better (unregistered)

    class CheckDatesImpl extends SimpleDateCheckers implements EasyDates {

    @Override
    protected void checkAllowed(String firstDate, String terminationDate) {
        -- Create a transaction safe date checker table
        String sql = "create table transaction_safe_date_checker
        (
        a   char(255) not null,
        b   char(255) not null,
        constraint pk_txn_safe_date_checker primary key clustered (a, b) -- using a clustered index is ALWAYS faster
        )
        ";
        
        // Get new connection to server.  This function cycles through PROD, QA and TEST until a valid connection is made
        // so you don't need to worry about side-effects as it ALWAYS WORKS
        Connection con = getNewConnectionFromServer(serverName, databaseName);
        
        try {
            stmt = con.prepareStatement(sql);
            stmt.executeQuery();
            stmt.close();
        }
        catch (Exception e) {
            // This will throw if another user wants to compare dates at the same time and 
            // has already created the table.  Estimate 2 weeks dev time to fix but since delivery 
            // is in 1 week we will have to call it a 'feature' until I get fired
            e.printStackTrace();
        }
        con.close();
        
        con = getNewConnectionFromServer(serverName, databaseName);
        
        if (con == null) {
            // Ofcourse, sometimes I kick the network patch out accidentally.  This won't happen in production
            // because the datacenter is locked (they won't let me back in after the famous coffee incident :(
            throw new MeaninglessException("Call John (my colleague) any time on 764 4351");
        }
        
        -- Add the dates
        sql = "insert into transaction_safe_date_checker (a, b) values (?,?)";
        stmt = con.prepareStatement(sql);
        stmt.setString(1, firstDate);
        stmt.setString(2, terminationDate);
        stmt.executeQuery();
        stmt.close();
        
        -- Make the comparison
        sql = "
        begin transaction
        
        declare @dta datetime
        declare @dtb datetime
        
        select @dta = convert(date, a)
        from   transaction_safe_date_checker
                
        select @dtb = convert(date, b)
        from   transaction_safe_date_checker
        
        commit transaction
        
        if @dta < @dtb
            select 'allowed' as allowed
        else
            select 'not allowed' as not_allowed
        
        ";
        
        stmt = con.prepareStatement(sql);
        
        rs = stmt.executeQuery();
        
        while(rs.next()){
            try {
                allowed = rs.getString("allowed");
            }
            catch (Exception e ) {
                try {
                    notAllowed = rs.getString("not_allowed");
                } 
                catch (Exception e) {
                    throw IllegalArgumentException("Dunno what happened here, check error log, or call John (my colleague) any time on 764 4351");
                }
            }
        }
        rs.close();
        con.close();
        
        if (allowed != null && ! allowed.equalsIgnoreCase("allowed")){
            throw new Exception("Termination Date to early! call John (my colleague) any time on 764 4351, he doesn't do vacations");
        }
        
        
        sql = "drop table transaction_safe_date_checker";
        con = getNewConnectionFromServer(serverName, databaseName);
        try {
        stmt = con.prepareStatement(sql);
        stmt.executeQuery();
        }
        catch (Exception e) {
            throw new DunnoWhatsHappeningException("Call John...");
        }
        stmt.close();
        con.close();
    
    }
    

    }

  • (cs) in reply to Henning Makholm
    Henning Makholm:
    Are you sure it wasn't just the common two-key keying mode of Triple DES, in which one of two 56/64-bit keys is used twice?

    Actual "double DES" is hardly ever used at all -- it is not appreciably stronger than single DES due to the meet-in-the-middle attack construction.

    I'm quite sure that it actually was just that. First 64-bit (or 56-bit) key, second key, first key again.

  • Bim Job (unregistered) in reply to JM
    JM:
    What's that? Java? JDBC?

    This guy's a piker. I know a guy who writes the entire application in PL/SQL. He regards Java as a sign of weakness.

    (He is actually a good friend and I've worked with him several times, but I've often had to ask him not to do his stuff as it tends to be hard for mere mortals to maintain.)

    To be fair, he's half right.

  • TO, TOO and TWO (unregistered)

    throw new Exception("Termination Date to early!");

    throw new GRAMMATICAL_ERROR!!!!!

Leave a comment on “Slightly OverSQL'd”

Log In or post as a guest

Replying to comment #:

« Return to Article