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

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.
  • This isn't necessarily anything wrong with using SELECT *, relying on the order of columns returned is the problem.

    I remember reading somebody saying that you should always use an ORDER BY clause in SQL, which is useless in the cases where order doesn't matter.

    Sometimes order does matter, sometimes it doesn't, it's about using the right tool for the job.
    • I know that I've said results returned should always use "ORDER BY" and I was (again) being stupid. I was pissed off at a programmer failing to sort his results properly and when I get annoyed, I say stupid things.

      In that case, the programmer eventually sorted the data, in Perl. That's usually stupid when the database can handle it. In our case it resulted in a bug whereby the data always had to be sorted but sometimes we were getting it before it had been sorted. The problem (and this is merlyn's point), is that logic should be applied as soon as it reasonable. If you only need name and rank, spell it out explicitly as in SELECT name, rank.... If you think you'll need all the columns, spell out all the columns. Then if someone renames "rank", your code will instantly break at the database level rather than some mysterious error deep in the application.

      SELECT * ... is usually a hack for lazy programmers and it hampers the poor maintenance programmer who has no idea what type of data is being returned.