Why there are Stored Procs
One of my least favorite features of MS SQL is the stored proc. Maybe it’s just the lack of a nice database management tool such as PHPMyAdmin that I have to work with.
However I discovered why they must exist: because open source developers are lazy and refuse to fix important bugs in any reasonable time frame.
Seriously, this problem has existed for at least 2 years. Apparently it’s too “niche” of a bug for anyone to take seriously and fix.
The problem is PHP’s ODBC driver. What is happening is simple; left joins are treated as though they are inner joins. And there’s no way around it. In ODBC land if you join table B onto table A and the join condition fails you don’t get a row even if you’re doing a left join and are supposed to. A left join is supposed to result in a row as long as the where clause is true regardless of the status of the join.
To get around this problem you have to put the query into a stored proc. The problem occurs when the ODBC driver tries to compile your query and pass it into MS SQL. So you just let MS SQL handle the query and have ODBC pass the EXEC call to the stored proc.
This problem is of course on top of the problem that the latest version of PHP comes with an ODBC driver that is completely incompatible with MSSQL 2005.
Sometimes open source is impressive. Most of the time there’s a whole lot of fail going on.
Leave a comment
You must be logged in to post a comment.