Sunday, March 25, 2012

comparing long varchar to char problems

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 a function on either of them would work ?

ThanksI've never tried it, but could you use Cast(myLongChar AS VARCHAR(1000)) or something like that?

-PatP|||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|||Ok, just for the jolly factor, lets assume that you are running an unpatched (or at least not current) version of DB2. As Lewis Grizzard used to say: Shoot low boys, they're riding Shetland Ponies!

Try to use Cast(myLongChar AS VARCHAR(250)) and see if that works better.

-PatP

No comments:

Post a Comment