Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Re: Null fields

by Tyke (Pilgrim)
on Mar 27, 2001 at 19:59 UTC ( #67521=note: print w/ replies, xml ) Need Help??


in reply to Re: Null fields
in thread Null fields

And how are null fields held in a CVS file? Just curious.


Comment on Re: Re: Null fields
Re: Re: Re: Null fields
by arturo (Vicar) on Mar 27, 2001 at 20:09 UTC

    Hmm, yes,

    my $csv_data = "foo,,bar"; foreach ( split /,/, $csv_data ) { print "'$_' => ", defined($_), "\n"; }

    Gives you

    'foo' => 1
    '' => 1
    'bar' => 1
    

    So that middle value is not undef, but "". Of course, since DBI's results are supposed to be as independent as possible of the underlying data structure, there may -- in fact, should -- be routines within DBD::CSV to convert "" to undef, which is what you'd expect to get if you were using an actual RDBMS. That's assuming it even uses something so crude as that split to get at the data =)

    /me is too lazy to look at the source code.
      Ah, but I always understood that '' was not the same as null, at least for strings. After all '' ne undef in Perl.

      On the other hand, I also believe that this distinction is database dependent :-(

      Update: As merlyn rightly points out, '' eq undef is true. I goofed.

        You're right, '' is not the same as NULL, at least in databases following the ANSI standard.
        This way you can always distinguish between 'something entered in this column, even if it's nothing'
        and 'nothing entered in this column'
Re: Re: Re: Null fields
by busunsl (Vicar) on Mar 27, 2001 at 21:25 UTC
    They are held as nothing between the commas, like this:
    12,"bla bla",,137

    The third is a NULL.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2014-08-20 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (124 votes), past polls