<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
I have a string field I wish to convert to int. A small subset of
the records contain NULL.<br>
I tried the following in the field calculator:<br>
<br>
<blockquote>case<br>
when ("bb_usage" IS NULL) then 0<br>
else to_int("bb_usage"")<br>
end<br>
</blockquote>
When I look at the preview, the result is correct whether or not the
field contains int or NULL. But when I try to run it, I get an
error:<br>
<br>
<img src="cid:part1.CE816897.79709941@stripfamily.net"
alt=""><br>
<br>
I also tried<br>
<br>
<blockquote>case<br>
when ("bb_usage" IS NULL) then 0<br>
when ("bb_usage" IS NULL) then to_int("bb_usage")<br>
end<br>
</blockquote>
and get the same error.<br>
<br>
I tried<br>
<blockquote>if ("bb_usage" IS NULL, 0, to_int("bb_usage"))<br>
</blockquote>
same error.<br>
<br>
I know there are workarounds, but why don't any of these work? Why
does to_int get evaluated on the NULLs?<br>
</body>
</html>