Re: How do you covert a number a character
Posted in 1994
In <3atjfr$q9f@s-cwis.unomaha.edu> jlofshul@s-cwis.unomaha.edu (Joseph M. Lofshult) writes: >A co-worker is trying to do a query in ISQL in which he wants to compare >a number field with a character field. The character field could >either contain digits or could be a mixture of characters and >digits. What he wants to do is to convert the number to a character >string before doing the comparison. Is there a way to do the conversion? >Or, is there another way to do the comparison? Along these lines, there is a bug/bad feature in 5.0's sql whereby a query containing ... foo = " " or foo between 1 and 10 ... in *some* instances (doesn't seem to be all, seems to depend on rest of query) will give a numeric conversion error if foo contains some alphas. Since SQL doesn't do short-circuit evalations (or 4gl, grrr), you can't get around it with ... foo = " " or (foo not matches "*[A-Z]*" and foo between 1 and 10)... since it still tries the 'between'. (And between "1" and "10" isn't numeric, so useless to me.) One might argue this is correct -- except for my data which may be alpha or numeric, and I need to be able to test (in one query) for it being in range if numeric. Oddly enough, though, it's (a) not a consistent failure, and (b) has a workaround: ... (foo+0) between 1 and 10... Why foo+0 is ok (and gives 0 for alpha), but foo-between isn't, I dunno... Just an FYI... -- Andrew Burt aburt@du.edu "But if he was dying he wouldn't bother to carve "Aaaaargh", he'd just say it."