| Henry's profileUtterances on Software E...PhotosBlogLists | Help |
|
March 05 Pit of despair: Error handling in SQL Server is seriously broken
Life is easy: foreach (KeyValuePair<string, string> criterion in criteria) { float value; //if (!float.TryParse(criterion.Value, out value)) //{ // value = defaultValue; //} try { value = (float)Convert.ChangeType(criterion.Value, typeof(float), CultureInfo.InvariantCulture); } catch (FormatException) { value = defaultValue; }
converted.Add(criterion.Key, value); } It could be even luxurious if we wouldn't have to deal with Transact-SQL type conversion and Error Handling.
That can possibly only be written by someone with a kinky approach to exception-handling. If anything, it might be somewhat inspired by Microsoft Basic.
DECLARE @Criteria TABLE ( [Name] nvarchar(200) NOT NULL, Value nvarchar(400) NOT NULL, NumValue float CHECK (0 < COALESCE(NumValue, 1)), PRIMARY KEY ([Name]) );
BEGIN TRANSACTION;
INSERT INTO @Criteria ([Name], Value) VALUES ('Pass', '4.2'); --INSERT INTO @Criteria ([Name], Value) VALUES ('Fail', '4;2'); INSERT INTO @Criteria ([Name], Value) VALUES ('Other', '0');
COMMIT TRANSACTION;
BEGIN TRANSACTION; BEGIN TRY UPDATE @Criteria SET NumValue = CAST(Value AS float); COMMIT TRANSACTION; END TRY BEGIN CATCH IF @@TRANCOUNT > 0 BEGIN ROLLBACK TRANSACTION; END
IF ERROR_NUMBER() <> 8114 BEGIN EXEC usp_RethrowError; END END CATCH Msg 50000, Level 16, State 1, Procedure usp_RethrowError, Line 31 Foomp! We just lost the error context. All we got is an error message that appears to look like the original error. Nice. This renders all subsequent, decoupled, generic, pluggable, configurable or otherwise smart error handling pointless. SQL Server traps us in the Pit of Despair. You can't filter You can't re-throw errors, because RAISERROR doesn't let you use an arbitrary msg_id. So, what is it that we learn from that? March 04 A match not made in heaven: Windows Server 2008 and HP ProLiant ML 110 G3Note to self: installing bleeding edge software on too-cheap hardware hurts. To not fall into the Vista trap again, I thought I'd rather start sooner than later testing software on Windows Server 2008. I'm playing on a HP ProLiant ML 110 G3, a little server with a 3GHz Pentium IV D and 3GB RAM, holding additionally 2 RAID-1-arrays with roughly 700 GB on a HP 6-port SATA RAID controller. Windows Server 2003 R2 SP2 was installed and running fine. HP confirms that the ProLiant ML 110 G3 supports Windows Server 2008 (Table 2, page 9), as well as the 6-Port SATA RAID controller (Table 3, page 11). But it ain't that easy. First, the upgrade failed. Because Powershell cannot be upgraded or removed. Then, the installation failed. Because it always traps into a NMI Parity error on restart. And I have good reason to assume it's not the memory because the Windows Memory Diagnostics Extended test ran in an infinite loop an entire weekend without detecting problems. Also, I can reproduce the NMI loading the 6-port SATA RAID controller's driver into Windows Server 2008 pre-setup. So, I invested another day trying to find firmware updates. For the system itself, for the iLO, for the 6-port SATA RAID controller. Funny: The iLO update works only with a diskette drive. Which the server doesn't have. Not even optionally. The all-new all-in-one HP ProLiant Firmware CD 8.00 does not support ML 100 series servers. That's something Pre-Sales doesn't tell you. So, this is the end of that. Hard to try being proactive with new operating systems if your hardware vendor let's you down. |
|
|