Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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.


Comment on Re: Perl DBI NULL and undef
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://991453]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2014-11-28 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (195 votes), past polls