At 2:36 PM +1000 5/9/01, Michael Blackmore wrote:
>Dear dbi-users,
>
>I know this is not strictly dbi, however it is a problem when trying to
>insert 0's into an Oracle database.  My problem is that I have a column in a
>table that can contain NULL, 0, or 1.  I want to read from this table and
>insert the data into another table, or update the data if it has changed so
>it is the same as the source table.
>
>source       Destination
>ID Column1   ID Column1
>1  NULL      1  0
>2  0         2  0
>3  1         3  1
>etc.
>
>Here I need to update Destination.Column1 to be NULL.
>
>The best I could come up with is:
>
>if ((length($i) == 0 && length($j) == 0) ||
>     (($i == $j) && length($i) == length($j))) {
>   return 1;
>}else{
>   return 0;
>}
>where:
>$i - value from source table
>$j - value in destination table

Way too complicated. NULL values are returned as undef.  Just used
defined ($var).

>
>Somehow, this does not leave me feeling all warm and fuzzy inside. Anyone
>have a better suggestion?
>Cheers,
>
>Michael
>([EMAIL PROTECTED])


-- 
Paul DuBois, [EMAIL PROTECTED]

Reply via email to