Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Perl DBI NULL and undef

by mje (Curate)
on Sep 03, 2012 at 15:27 UTC ( #991453=note: print w/replies, xml ) Need Help??

in reply to Perl DBI NULL and undef

SQL> create table mje (a int, b varchar(10) null default null); SQLRowCount returns -1 SQL> insert into mje (a,b) values(1,'fred'); SQLRowCount returns 1 SQL> insert into mje (a,b) values(2, ''); SQLRowCount returns 1 SQL> insert into mje (a) values(3); SQLRowCount returns 1 SQL> select * from mje; +------------+-----------+ | a | b | +------------+-----------+ | 1 | fred | | 2 | | | 3 | | +------------+-----------+ SQLRowCount returns -1 3 rows fetched
perl -MDBI -le 'my $h = DBI->connect; use Data::Dumper; my $r = $h->se +lectall_arrayref("select * from mje");print Dumper($r);' $VAR1 = [ [ 1, 'fred' ], [ 2, '' ], [ 3, undef ] ];

So empty strings in this case are defined and NULLs in the databases are returned as undef in Perl. undef is a Perl thing and NULL is a SQL thing so when you say "How can I separate the undef data and NULL data" it does not make sense.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://991453]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2018-05-22 00:57 GMT
Find Nodes?
    Voting Booth?