From: Carville, Stephen" <[EMAIL PROTECTED]>
> I've tried several different ways, global variables, local variables,
> modules but, FWIW, I've found putting long scripts in a subroutine
> works pretty well from a maintenance standpoint: (This is from an
> older report.  Now I encourage the poor guy who has to maintain my
> stuff to use ? instead of %s whenever practical) 
> 
> sub some_descriptive_script_name {

While prototypes are generaly not recommended this is a perfect case 
for the empty prototype

 sub some_descriptive_script_name () {

which will basicaly turn the subroutine into a constant that can be 
inlined.

> return qq{

Looks to me like you are not interpolating any variables there so q{} 
would probably be better.

Of course it would definitely be preferred to use placeholders 
instead if inserting the data into the SQL with sprinf(). It's safer 
and more efficient (allows the database to cache execution plans).

If supported by the database, stored procedures would work even 
better. Especially if you enforce a rule that all database access is 
doen via stored procedures and therefore the DBA has a chance to see 
all SQL used against his database and can optimize the queries and/or 
indexes and schema.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery

Reply via email to