[nfbcs] Counting parentheses

John G Heim jheim at math.wisc.edu
Mon Oct 26 18:23:48 UTC 2015



I'd try the counting technique first unless the query is really long. In 
that case, i'd try the indentation technique. A variation of the 
indentation technique is to cut out a chunk of code between what  you 
think are balanced parens. Run the query to make sure it works. Paste 
the code back in and cut out a smaller chunck. Repeat until you've 
narrowed the problem down to a single small chunk of code. Then use the 
counting trick.


Of course, another thing you can do is get an editor that helps you 
match parens.







On 10/26/2015 12:44 PM, Tracy Carcione via nfbcs wrote:
> Jim, I'm just using Notepad, or editing in the New Query panel in SQL
> Server.  Should I be using something more sophisticated?
>
> John and Gary, I'm trying to do what you said, but some of the closing
> parens are a long way from the opening ones.  Guess my brain needs more
> exercise.  And thanks John--clearly I'd better stick to betting the
> ponies, and stay far away from Vegas. :.)
>
> Aaron, it never occurred to me I could buy a new abacus.  I'll look into it.
> Tracy
>
>> Oh lord that sounds Tedious <grin>
>>
>> I don't know what editor you're using, but most editors have paren
>> balancing keystrokes you can use to bounce between the opening and
>> closing paren.  I've used this to great effect to figure out where
>> I've dropped a paren.
>>
>> Jim
>>
>> On Mon, Oct 26, 2015 at 12:18:35PM -0500, John G Heim via nfbcs wrote:
>>> Listen to the sql query a character at a time adding 1 to the count each
>>> time you cursor over a left paren and subtracting one each time you
>>> cursor
>>> over a right paren.  It's like how they count cards in Vegas.
>>>
>>>
>>> The only problem with this method is that you might get to the end of
>>> the
>>> query and discover that you are missing a parenthesis but it might not
>>> be
>>> clear where. What I would do in this case is do it again, this time
>>> listening for the point where I know I should subtract 1 instead of add.
>>> Or
>>> just take a shot and put a right paren at the end which is almost always
>>> the
>>> solution anyway.
>>>
>>>
>>>
>>>
>>> On 10/26/2015 12:01 PM, Tracy Carcione via nfbcs wrote:
>>>> I am having trouble keeping track of parentheses in complicated SQL
>>>> statements.  Perhaps when I know SQL better, it will be less confusing.
>>>> Sometimes I have an abacus handy to keep track of counts, but not
>>> always.
>>>> What methods do people use to make sure there is a ) for each (?
>>>> Thanks.
>>>> Tracy
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> nfbcs mailing list
>>>> nfbcs at nfbnet.org
>>>> http://nfbnet.org/mailman/listinfo/nfbcs_nfbnet.org
>>>> To unsubscribe, change your list options or get your account info for
>>> nfbcs:
>>>> http://nfbnet.org/mailman/options/nfbcs_nfbnet.org/jheim%40math.wisc.edu
>>>>
>>>
>>> --
>>> John Heim, jheim at math.wisc.edu, 608-263-4189, skype:john.g.heim,
>>> sip:jheim at sip.linphone.org
>>>
>>> _______________________________________________
>>> nfbcs mailing list
>>> nfbcs at nfbnet.org
>>> http://nfbnet.org/mailman/listinfo/nfbcs_nfbnet.org
>>> To unsubscribe, change your list options or get your account info for
>>> nfbcs:
>>> http://nfbnet.org/mailman/options/nfbcs_nfbnet.org/jbar%40barcore.com
>>>
>>
>> _______________________________________________
>> nfbcs mailing list
>> nfbcs at nfbnet.org
>> http://nfbnet.org/mailman/listinfo/nfbcs_nfbnet.org
>> To unsubscribe, change your list options or get your account info for
>> nfbcs:
>> http://nfbnet.org/mailman/options/nfbcs_nfbnet.org/carcione%40access.net
>>
>
>
>
> _______________________________________________
> nfbcs mailing list
> nfbcs at nfbnet.org
> http://nfbnet.org/mailman/listinfo/nfbcs_nfbnet.org
> To unsubscribe, change your list options or get your account info for nfbcs:
> http://nfbnet.org/mailman/options/nfbcs_nfbnet.org/jheim%40math.wisc.edu
>

-- 
John Heim, jheim at math.wisc.edu, 608-263-4189, skype:john.g.heim, 
sip:jheim at sip.linphone.org




More information about the NFBCS mailing list