Railo Error Message
invalid call of the function getJerseyColor (), first Argument (Color) is of invalid type, can't cast String  to a value of type [numeric]
Using a UDF (User Defined Function) created to convert a numeric value to a string within a returned query. We have an integer stored in the database table which represents a color value. It is much easier for the user to actually read the color name instead of mentally trying to convert the number to a the color value each time. We are actually looking at Jersey colors and Jersey numbers, so coaches and evaluators can quickly and easily identify each player.
Here's the UDF:
<cfargument name="Color" type="numeric" required="true" />
<cfset var JerseyColor = "" />
<cfset JerseyColor = "Yellow" />
<cfset JerseyColor = "Blue" />
<cfset JerseyColor = "Purple" />
<cfset JerseyColor = "Yellow/Blue" />
<cfset JerseyColor = "Green/Blue" />
<cfreturn JerseyColor />
Here's how the UDF is called:
Here it is utilized replacing the returned query value for "Color":
SELECT playerid AS "ID",
rate1 AS "Color",
rate2 AS "Num"
<!--- make jersey color human readable --->
<cfset filterPlayer.Color = getJerseyColor(filterPlayer.Color) />
Now about the error....
Testing on development produced no error, while Production generated the error. Both columns in each MySQL database were numeric, of type smallint(6) and defaulted to Null. In this case, we are talking about "rate1" column aliased as "Color". The only difference between the two database columns was that the development MySQL database had actual numeric values in each row. Production had Null values in every "rate1" column row.
Doing a little reasearch, mainly Googling "can't cast string to a number value" turned up some issues about Railo and null values while casting strings to numbers. Some pondering led to realization that the column needed non Null numeric values to allow the UDF to run.
The solution was to replace the Null values in the numeric int() column to actual numeric values. Setting to 0 (zero) worked. Now the UDF runs perfectly.