SQL datatype comparison help

rh71

No Lifer
Aug 28, 2001
52,844
1,049
126
field used to be comparing varchar to char such as this and it worked ok:
WHERE firstname = username

now the field is comparing long varchar vs. char:
WHERE thefullname = username

and it's returning this error:
Improper use of a string column, host variable, constant, or
function "". SQLSTATE=42907

Is there any way I can still compare these two fields ? It must be these fields so maybe some kind of conversion function on either of them would work ?

Thanks
 

Lint21

Senior member
Oct 9, 1999
508
0
0
Did you try casting the char as a varchar?

where thefullname = cast(username as varchar)

I don't know if that's the problem, though. This could be something different, but I'm not sure what.
 

rh71

No Lifer
Aug 28, 2001
52,844
1,049
126
thanks but the cast function created the following error:

SQL0604N The length, precision, or scale attribute for column, distinct type,
structured type, attribute of structured type, function, or type mapping "" is
not valid. SQLSTATE=42611
 

stndn

Golden Member
Mar 10, 2001
1,886
0
0
i believe you need to quote the value in strings?
WHERE thefullname = 'username'

don't think the varchar or char matters....