Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

  (email not shown publicly)
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Monday March 17, 2003
12:20 PM

Keeping silent

[ #11072 ]

Despite my wanting to respond more to some comments made regarding my anti-war post, I'm not going to. I posted out of frustration and I would certainly prefer for this to be more a Perl forum than a political one (well, at least for me. Others, of course, are free to do as they will). I have no problem discussing issues like this, but this is not a forum where I feel comfortable doing that and I shouldn't have made that last post. 'nuff said!

And just so I can keep this marginally Perl related: I'm thinking about putting together a presentation for the next Portland Perl Mongers meeting. Tentative title is use strict 'sql';. I'm getting closer to the point where I feel that any hard-coded SQL for programs that are part of a large system is a bad thing. For short scripts, I don't have a problem with it, but for larger programs, SQL is abused very, very heavily. It's time to tell people that.

A symptom of this showed up in our last Perl Mongers meeting. A fellow programmer told me that they had such a huge database and such a large body of code to go with it that there was no way the dared to alter their database. That shouldn't happen and I'll tell people why.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • managing your sql (Score:3, Informative)

    by TeeJay (2309) on 2003.03.17 13:04 (#17990) Homepage Journal
    You want some kind abstraction you do :)

    Have you tried Class::Phrasebook ?

    We have started using it here for our SQL and it has made life a bit easier.

    Our SQL is slowly leaving cgi scripts and getting buried deeper into our module library, which makes for a much easier life.

    This is one of the reasons I really want CPD (copy and paste detector) for perl - many SQL queries at cgi script level can be munged down into a single function in a module somewhere or even stashed into a dictionary of queries somewhere.


    @JAPH = qw(Hacker Perl Another Just);
    print reverse @JAPH;
  • by djberg96 (2603) on 2003.03.17 13:09 (#17991) Journal
    I admit it - I've hardcoded sql into my programs before, though I haven't done it in any *major* programs - just short scripts.

    What I do now is keep the sql in a separate file, occasionally using a special comment so I can slurp the sql into memory (in paragraph mode) and use the special comment as a hash key (with the sql as the value for that key) so I don't have to remember the order of the sql. e.g.

    --0 some query
    select foo from bar where foo = 1

    --1 another query
    select baz from bar where baz = "Y"
    Then after slurping the file, I end up with a hash that looks like:
       0 => 'select foo from bar where foo = 1',
       1 => 'select baz from bar where baz = "Y"'
    The other advantage of having the sql separated is that you can do separate version control for that file, and change the sql without having to rerelease the calling script. Probably obvious - just thought I'd mention it for anyone else. :)

    Depending on my needs I don't always do the hash trick thing. Or am I doing things totally stupid? Gonna post your talk afterwards? I'd like to read it.

  • Silence is Evil - spread the word. []

    Sorry, I couldn't help it! Seriously, I would prefer to keep political discussions to a minimum on use.perl, also.

    I told my wife that I wasn't going to get pulled into another such discussion here, but I found I couldn't resist. I don't think this is a good thing. Lord knows, I have a lot more important things on which to focus.

    If everybody promises not to bring up politics, I promise not to respond!

    • Re:But... (Score:3, Interesting)

      Heh :) The link is merely a passive statement of some of my beliefs (that is to say, the link is a passive way to present how I feel, the content of the link is clearly not passive). As such, it doesn't bother me as much. It's when I explicitly take the time to rant about a particular subject when I realize that it's not something that I really want to do. Rarely are such things productive. Of course, I still seem to do that a lot even when I try to minimize it. On the other hand, if I merely present

      • Re:But... (Score:2, Insightful)

        Me too.

        I'm sorry when I don't, so you very definitely have my apologies for my posting out of frustration.

      • If everybody promises not to bring up politics, I promise not to respond!

      Well, I did it. I posted my own provocative Journal entry about the War.

      Technically, I'm not a hypocrit. I promised not to respond only IF people didn't bring up politics. I didn't promise not to bring up politics myself!

  • A fellow programmer told me that they had such a huge database and such a large body of code to go with it that there was no way the dared to alter their database.
    Sounds a bit like Big Ball Of Mud [], or possibly Amorphous Blob Of Human Insensitivity [].
  • two things (Score:2, Insightful)

    1. I don't necessarily agree with your stance but I respect your opinions and I have no problem with you airing them here.

    2. I too work with a very SQL intensive web app and I'm convinced that no matter where the SQL winds up (cgi, modules, stored proc), it ends up being a big ball of mud. It takes a lot of planning and a lot of discipline to keep the SQL where you've decided to keep it. Too many times we look for technical solutions (stored procs, Class::Phrasebook, etc) where manual solutions (design an