Monday, October 31, 2005

Dear Mr. Vick

I wanted to lend some support to a great idea I heard from Paul Vick on .NET Rocks!

"Heard you on .NET Rocks! mention the possibility of doing away with VB's line continuation character - presumably making it more C-like in its treatment of whitespace. I think this would be GREAT!

"I have come to VB from a long history of C and C++ and (especially with VB.NET) the only think that has really niggled is VB's line-oriented parser.

"I expect you'll have to pull off some pretty neat tricks with context-sensitive parsing but please, please please do it!"

Friday, October 28, 2005

SQL Surprise

Got tripped up by this little bit of SQL (which I naively bashed out in Query Analyzer):

select * from Addresses where AddrID in
(select AddrID from BankAccounts where BankID=234255)

The BankAccounts table includes a foreign key to Addresses, giving the address of the branch at which the account is held (there is no intermediate BankBranches table). So I was expecting this query to give me one row from Addresses (or perhaps none). In fact, it gave me the whole damn table.

The problem is that the BankAccounts table doesn't have an AddrID column; it's called BankAddrID. So why didn't the query give an error? I'm no SQL expert but basically it's because the outer select is in scope (which allows correlated subqueries to work) so the query I wrote was effectively:

select AddrID from Addresses
cross join BankAccounts
where BankID=234255