June 2006 Entries
ExecutionEngineException, TypeMock.Net and VS 2003 Debugging

Firstly who hasn't checked out TypeMock.NET http://www.typemock.com really should, this is by far the easiest to use and advanced mocking framework I have used.

There are, however, a few kinks...

From time to time you may find you get an ExecutionEngineException exception whilst debugging code in Visual Studio 2003 (Haven't checked 2005). To be honest this is not too surprising considering the magic that is going on under the scenes with typemock and to be fair these types of issues are rapidly being fixed in frequent updates.

A complete rebuild of your solution will often make this issue go away, however if the problem persists it may be better to simply disable the Visual Studio integration and run TypeMock based tests outside of the IDE.

Bitwise Operations in PLSQL

Looking around on the web I have found numerous posts complaining about the lack of bitwise operators in Oracle. Although Oracle does not seem to directly support bitwise operations on number types it does have support for bitwise operations on the raw type via the utl_raw package. With a little bit of type manipulation it is relatively easy to leverage these routines for use with number types.

create or replace package K_NUMBER_UTIL is
   
  function ToRaw(p_Value number) return raw;
  function BitOr(p_Value1 number, p_Value2 number) return number;
  function BitXor(p_Value1 number, p_Value2 number) return number;
  function BitAnd(p_Value1 number, p_Value2 number) return number;

end K_NUMBER_UTIL;
/
create or replace package body K_NUMBER_UTIL is
 
  RawToNumberFMT constant char(12) := 'XXXXXXXXXXXX';
  NumberToRawFMT constant char(14) := 'FM' || RawToNumberFMT;
 
  function ToRaw(p_Value number) return raw is
  begin
    return HexToRaw(To_Char(p_Value, NumberToRawFMT));
  end;
 
  function BitOr(p_Value1 number, p_Value2 number) return number is
  begin
    return To_Number(utl_raw.bit_or(ToRaw(p_Value1), ToRaw(p_Value2)), RawToNumberFMT);
  end;
 
  function BitXor(p_Value1 number, p_Value2 number) return number is
  begin
    return To_Number(utl_raw.bit_xor(ToRaw(p_Value1), ToRaw(p_Value2)), RawToNumberFMT);
  end;

  function BitAnd(p_Value1 number, p_Value2 number) return number is
  begin
    return To_Number(utl_raw.bit_and(ToRaw(p_Value1), ToRaw(p_Value2)), RawToNumberFMT);
  end;
 
end K_NUMBER_UTIL;
/

One Comment Filed Under [ Oracle ]