On Tue, March 8, 2011 10:09, Scott Ribe wrote:
> On Mar 8, 2011, at 7:54 AM, James B. Byrne wrote:
>
>> My question is: Why am I getting a NULL exception?
>
> Because you're trying to insert NULL explicitly?
Yes, that is the problem. Evidently RoR's ActiveRecord helpfully
converts a string containing nought but spaces to nil when a numeric
value is required for the column type. The problem arises with a
single unit record received from the government system that has a
UOM code provided but the associated decimal value field is blank.
Since the default is zero in our DB I have altered our load program
to coerce a value of zero for strings containing only spaces
destined for numeric columns. But, it feels ugly. I would really
like to be able to coerce nils to some value on a column by column
basis on the DBMS side. This is not really a DEFAULT value and I do
not know what I would call it if such a thing did exist. I suppose
a trigger and function is called for.
Thanks for the help.
--
*** E-Mail is NOT a SECURE channel ***
James B. Byrne mailto:ByrneJB@Harte-Lyne.ca
Harte & Lyne Limited http://www.harte-lyne.ca
9 Brockley Drive vox: +1 905 561 1241
Hamilton, Ontario fax: +1 905 561 0757
Canada L8E 3C3