From: Martin Rieder <Martin dot Rieder at morganstanley dot com>
Subject: Re: Null Value problem with Sybase::BLK
Date: Jun 18 2002 2:56AM
Hiroshi,
I had a similar problem with "null" integer fields: undef in integer context is a zero, which
is what is being loaded. I run through my array of data checking each numeric field and
explicitly set the null fields to undef with something like:
$data[$i] = undef if ( $data[$i] eq undef ) # I use eq, not ==
This will make sure that the values are interpreted as undef and will correctly insert a NULL.
Martin
山田 裕 wrote:
> Hi, I'm new to the mailing list.
>
> I am in trouble with Sybase::BLK.
> It's concerned with Null values.
>
> Here is an exmaple,
> which BULK-inserts the following three rows by blk_rowxfer().
>
>
> ------------------------------------
> id, status, col1, col2, col3
> ------------------------------------
> 0, OK, 100, 100, 100
> 1, OK, 0, 0, 0
> 2, NG, , ,
> ------------------------------------
>
> Rows with id = 0,1 are normally inserted,
> while the row id = 2 is inserted with zeros, not with NULLs, on col1,2,3.
>
>
> ------------------------------------
> id, status, col1, col2, col3
> ------------------------------------
> 0, OK, 100, 100, 100
> 1, OK, 0, 0, 0
> 2, NG, 0 , 0, 0 <== ZEROS!
> ------------------------------------
>
> Col1,2,3 are all of integer type.
>
> I understand that the undef values in Perl are converted into null values in Sybase::BLK,
> aren't they?
>
> Please instruct me how to solve the problem.
>
> I have appended a perl script which demonstrates the above problem.
> The problem occured in an evironment:
>
> OS : AIX 4.3
> Perl :5.005_03
> Sybase:11.9.2.3(AIX)
> Open Client:11.1.1
> sybperl:2.1401
>
> Thank you in advance!!
>
> Hiroshi Yamada