SQL call formatting style

Sergey A. Lipnevich sergeyli at pisem.net
Tue Mar 25 18:19:38 UTC 2003


I didn't think this discussion is about /parameters/, and so far I'm 
justified by other opinions. The policy itself looks good but has 
nothing to do with how to code these long parameters, as one multiline 
value or several concatenated chunks. Sorry if I misunderstood...

Jason Pyeron wrote:
> 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>
> 
> 





More information about the developers mailing list