Tim was browsing through some stored procedures on an application he was working on and came across this ...
CREATE PROCEDURE SelectVendors AS BEGIN SELECT vendorNum, vendorType, vendorDept, inactiveDate FROM Vendors WHERE inactiveDate IS NULL ORDER BY vendorNum SELECT vendorNum, vendorType, vendorDept, inactiveDate FROM Vendors WHERE inactiveDate IS NOT NULL ORDER BY vendorNum END
Natrually, his first reaction wasn't "WTF", but more along the lines of "okaaaayy ..." After all, maybe the data layer does something different with active and inactive vendors, right? A search for the procedure name found a single function accessing it ...
Tim was browsing through some stored procedures on an application he was working on and came across this ...private ArrayList GetVendors() { SqlConnection myConn = getConnection(); SqlCommand myCommand = new SqlCommand("SelectVendors", myConn); myCommand.CommandType = CommandType.StoredProcedure; myConn.Open(); SqlDataReader myReader = myCommand.ExecuteReader(); ArrayList myVendorList = new ArrayList(); while(myReader.Read()) { Vendor myVendor = new Vendor(); myVendor.Number = myReader.GetInt32(0); myVendor.Type = myReader.GetString(1); myVendor.Deptartment = myReader.GetInt32(2); if (myReader.IsDBNull(3)) myVendor.InactiveDate = SqlDateTime.Null; else myVendor.InactiveDate = myReader.GetDateTime(3); myVendorList.Add(myVendor); } myReader.NextResult(); while(myReader.Read()) { Vendor myVendor = new Vendor(); myVendor.Number = myReader.GetInt32(0); myVendor.Type = myReader.GetString(1); myVendor.Deptartment = myReader.GetInt32(2); if (myReader.IsDBNull(3)) myVendor.InactiveDate = SqlDateTime.Null; else myVendor.InactiveDate = myReader.GetDateTime(3); myVendorList.Add(myVendor); } myReader.Close(); myConn.Close(); return myVendorList; }
And that, right there, is enough for the WTF reaction. Unless, of course, anyone can think of a reason for creating two results sets only to combine them in the data layer and, in another data layer function, sort them ...
[Advertisement]
BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!