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