Keeping silent

Ovid on 2003-03-17T17:20:16

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.


managing your sql

TeeJay on 2003-03-17T18:04:35

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.

Wish I could be there

djberg96 on 2003-03-17T18:09:35

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:
$sql_hash{
   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.

But...

jordan on 2003-03-17T18:50:18

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

Ovid on 2003-03-17T19:16:51

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 a topic without comment ... hmm ...

Mind you, I'm not saying that presenting one's beliefs here is wrong. It's not my site nor do I want to dictate the actions of others. I'm just trying to be careful about what I do.

Re:But...

chromatic on 2003-03-18T03:03:07

Me too.

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

Re:But...

jordan on 2003-03-24T17:48:52

  • 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!

re: manage your sql

jdporter on 2003-03-18T05:34:13

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

derby on 2003-03-18T14:03:54

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 and code reviews) are best.

-derby