Hi all,
I have been working on a module at work, and something came up that i thought would create, if nothing else, an interesting debate. First, i will explain what i am working with, then, what i have done.
My first module, is to allow access to the main job table, which contains the job_name (key), and the general job information, including schedule. Here come the part that people seem to object to ...
from the frivolous to the serious
I have been working on a module at work, and something came up that i thought would create, if nothing else, an interesting debate. First, i will explain what i am working with, then, what i have done.
The Job
We have a process by which a table is filled with job-specific data for a great number of processes. These include scheduling information, runtimes, success and failures, etc (Data held over several tables, etc) . I am working on a module to allow generalised access to this data, for the obvious reasons.My first module, is to allow access to the main job table, which contains the job_name (key), and the general job information, including schedule. Here come the part that people seem to object to ...
The Sin
I am using SELECT * in my SQL. Now, before my fellow monks fall dead to the floor, let me explain. The new() constructor takes a job name. The new() constructor, then uses DBI and DBD::Sybase to query the database using fetchrow_hashref(). Then, i set a key in my hash-ref-object to the hashref returned. To date i have heard nothing in code reviews but "Never use select *", but the reason for that is that your code will break if a field is ever added.I think that in my case, using select *,fetchrow_hashref() and AUTOLOAD makes the module more flexible when columns are add/removed/reordered.A Moral ?
I am interested to see if anyone thinks that i should not be using select *, and if they have any reason other than superstition. I must say, i have always said to people not to use it, but i think i may have found an exception... Let me know what you think.from the frivolous to the serious
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Module Pondering
by Masem (Monsignor) on Jan 18, 2002 at 21:23 UTC | |
(Ovid - more "Death to Select Star") Re: Module Pondering
by Ovid (Cardinal) on Jan 18, 2002 at 21:48 UTC | |
Re (tilly) 1: Module Pondering
by tilly (Archbishop) on Jan 19, 2002 at 10:46 UTC | |
Re: Module Pondering
by tadman (Prior) on Jan 18, 2002 at 22:56 UTC | |
Re: Module Pondering
by z3d (Scribe) on Jan 21, 2002 at 00:23 UTC | |
by jeffa (Bishop) on Jan 21, 2002 at 00:30 UTC |
Back to
Meditations