SQL call formatting style

Jason Pyeron jason at pyeron.com
Tue Mar 25 16:04:57 UTC 2003


Guaranteed not to like this opinion or your money back...

Here this is from our coding policy:

Scan ability of parameters is highly important. If a string or formula is 
so long that it has to wrap multiple lines, then it should be the last 
item which needs to be read for the snippet of code.

When wrapping lines always use a concatenation symbol.

When there are no other parameters or the long string is the last 
parameter:
 
foo(
 "This is a really long dialog message, it may be necessary to wrap"+
 "lines, and if it is passed by value to a function, special"+
 "formatting rules may apply."
);

bar(99,0,varX,
 "This is a really long dialog message, it may be necessary to wrap"+
 "lines, and if it is passed by value to a function, special"+
 "formatting rules may apply."
);

But when there are other parameters after the long string, the long string 
must be stored in a local var:

string msg= 
 "This is a really long dialog message, it may be necessary to wrap"+
 "lines, and if it is passed by value to a function, special"+
 "formatting rules may apply.";

bar(msg,99,0,varX);

Jason Pyeron

On Tue, 25 Mar 2003, Sergey A. Lipnevich wrote:

I started coding SQL like this (as scalar, akin to shell's cat << EOF 
... EOF) some time ago and now I hate when the language that doesn't 
allow that (e.g. Java). In situations like Java+SQL I'm willing to go 
extra length and store SQL in external config file, but not concatenate
clauses together in the code. It's absolutely worth it, and 
parameterized (prepared) statements with question marks are what they 
call "enabler" in this case. My $.0029/line.

Bradley Baetz wrote:
> See my comments in the bug for why I think my way is better. Lots of " .
> " suck, basically, especially since we are no longer doing
> interpoliating, and " . sqlQuote($foo) . " everywhere, but are using
> laceholders instead.
> 
> Bradley
> ----
> To view or change your list settings, click here:
> <http://bugzilla.org/cgi-bin/mj_wwwusr?user=gcbd-developers@gmane.org>
> 


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