Bleed the Freak


It's funny, but every time in my entire career that I've faced a you-can't-get-there-from-here when writing code, it's been resolved by listening to Alice in Chains.  Tonight's song: Bleed the Freak

I honestly have no idea what to think of that.

Oh, well.  At any rate, another life saved ;-)>.  Who knew that, when writing a db2 stored procedure,  Get Diagnostics ROW_COUNT could be confused by a variable assignment within the select statement.  Now I know.

Here's the code snippet in case anyone stumbles across this and needs it.  Hopefully it's clear.  v_vTable and SWV_RowCount were previously declared, as was v_last_block.:
--    The following is absolutely terrible, but GET DIAGNOSTICS ROW_COUNT simply would not work!!! 
--    It was returning 0 no matter what, perhaps confused by the INTO clause?

SET SWV_RowCount = (select count(N_OID_LST) FROM OID_MGMT WHERE C_OID_CL_ABR = v_vTable);
--      GET DIAGNOSTICS SWV_RowCount = ROW_COUNT;   
select N_OID_LST into v_last_block FROM OID_MGMT WHERE C_OID_CL_ABR = v_vTable;

Comments

Popular posts from this blog

Detecting Transaction Isolation Level through Profiler Trace and other means on MS SQL Server 2005

Regular Expressions in SQL Server, DB2 UDB, and Oracle