Removed manual SQL.valueOf calls.
Updated code.