SQL call formatting style
bbaetz at acm.org
Tue Mar 25 14:03:57 UTC 2003
On Tue, Mar 25, 2003 at 08:53:22AM -0500, Christopher Hicks wrote:
> Having the SQL statement in a scalar makes the $dbh calls much cleaner.
> It also allows you to easily replace extra whitespace with a single space
> if you'd like to do so for logging.
logging would be done via the DBI trace stuff, so thats not an issue. As
I mentioed in the bug, though. I especially prefer whitespace when
debugging. Splitting up the various clauses is a lot easer on teh eyes
than one jumbled-together string.
Well, thats a separate issue. Our more coplicated sql queris (ie
BugList.pm) have to be autogenarated to a scalar. The majority are just
simple selects, though.
> An acceptable alternative should allow for the SQL statement to be built
> up across a chunk of code:
> my $sql = "select ";
> $sql .= join(', ', at whatweneed);
> $sql .= " from sometable";
*cough* subselect *cough*
> By putting the SQL in a scalar it's easy to gclean it up before logging
More information about the developers