SQL call formatting style

Jason Pyeron jason at pyeron.com
Tue Mar 25 23:36:41 UTC 2003


use the quoting type of prefernce...

my $tmpsql="SELECT some SQL variables
 ON multiple lines
 IF necessary
 AND enclosed in quotes
 BECAUSE we all understand them
 WITH placeholders ?, ?, ?";

my ($comma, $separated, $list, $of, $vars, $on, $one, $line) =
  $dbh->some_longwinded_methodname($tmpsql,undef,
                                   $placeholder, $variables, $here);

is much better to read.

On Tue, 25 Mar 2003, Gervase Markham wrote:

If we are to allow newlines, then my proposal would become:

   my ($comma, $separated, $list, $of, $vars, $on, $one, $line) =
     $dbh->some_longwinded_methodname("SELECT some SQL variables
                                       ON multiple lines
                                       IF necessary
                                       AND enclosed in quotes
                                       BECAUSE we all understand them
                                       WITH placeholders ?, ?, ?",
                                      undef,
                                      $placeholder, $variables, $here);

I believe this strikes a reasonable balance between clarity and 
longwindedness. It may be true that if you space the SQL out a lot, it's 
easier to read the SQL - but it's much harder to follow the flow of the 
code around it.

Re: Myk's point: when do we ever do queries with newlines embedded in 
the query data?

Gerv

----
To view or change your list settings, click here:
<http://bugzilla.org/cgi-bin/mj_wwwusr?user=jpyeron@pyerotechnics.com>


-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-                                                               -
- Jason Pyeron                   http://www.pyerotechnics.com   -
- Owner & Lead                  Pyerotechnics Development, Inc. -
- +1 410 808 6646 (c)           500 West University Parkway #1S -
- +1 410 467 2266 (f)           Baltimore, Maryland  21210-3253 -
-                                                               -
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

This message is for the designated recipient only and may contain 
privileged, proprietary, or otherwise private information. If you
have received it in error, purge the message from your system and 
notify the sender immediately.  Any other use of the email by you 
is prohibited.






More information about the developers mailing list