I would change the name when to a not reserved name.
WHEN is a
reserved word.
Using reserved words in
SQL could lead to VERY STRANGE errors.
I (and mkinzler) recommend to change the name of the field.
PS: don't set ParamType to ptUnknown! Set it to ptInput.