Tim Bunce wrote:
On Fri, Jan 11, 2008 at 12:14:03PM +0000, Victor Churchill wrote:
On 11/01/2008, Colin Wetherbee <[EMAIL PROTECTED]> wrote:

(As an aside, how do you guys quote your queries?  I find that for
anything longer than about 60 characters, q() and '' and everything else
start to look horribly inelegant.)
Can't comment on your main question, but on the secondary query-layout
topic, I find this works quite nicely:
    $query2  = qq/SELECT MTR_REFERENCE FROM ALLOCATED_METERS,METERS /;
    $query2 .= qq/WHERE ALM_MTR_ID = MTR_ID                         /;
    $query2 .= qq/AND ALM_LP_ID = (                                 /;
    $query2 .= qq/  SELECT LP_ID                                    /;
    $query2 .= qq/  FROM LOGGER_POINTS,ALLOCATED_METERS,METERS      /;
    $query2 .= qq/  WHERE LP_ID=ALM_LP_ID                           /;
    $query2 .= qq/  AND MTR_ID=ALM_MTR_ID                           /;
    $query2 .= qq/  AND MTR_REFERENCE = ? )                         /;

(In a mono font the right hand /;'s align, for neatness, but that's optional).

Nice thing doing it this way is that it does not confuse the editor's
auto indent.

On the other hand, you can't easily copy-n-paste the query into other
tools, which I'd find much more frustrating. I'd also find the extra
line noise distracting. And when the query needs changing I'd find the
extra effort to maintain that layout would be a pain, literally.

Agreed.  I'd rather not have my query broken up like that.

I almost always use q{} or qq{} for multi-line strings.

(Using a bracketing character like {, (, [ etc. means that perl will
also take care of skipping any nested brackets within the string without
them beeding to be escaped.)

That sounds good. I would think q{} would be the best choice for SQL, since () and [] are common SQL characters. Not that it really matters in terms of Perl functionality, but I'd imagine it's at least slightly less confusing in the long run.

Thanks.

Colin

Reply via email to