CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
null DB entries

 



scarab
Deleted

Jun 26, 2000, 8:29 AM

Post #1 of 2 (542 views)
null DB entries Can't Post

I'm trying to ignore rows with a null value in the INET2 table (in the following code). The DB is MSSQL 7 (blargh) and I'm using FreeTDS and DBD::Sybase. Calling the database is great, and I can somewhat identify them with the gt ' ' eval, but I can't seem to figure out why these null values aren't exactly null.

Enlighten me,
scarab.

-- code --

#!/usr/bin/perl

use DBI;

$data_source = 'dbi:Sybase:server=myip';
my $dbh = DBI->connect($data_source,'user','pass', {PrintError => 0}) | | die $DBI::errstr;

my $sth = $dbh->prepare( q{
SELECT *
FROM SY01200
}) | | die "Can't prepare statement: $DBI::errstr";

my $rc = $sth->execute
| | die "Can't execute statement: $DBI::errstr";

while (($Master_Type, $Master_ID, $ADRSCODE, $INET1, $INET2) = $sth->fetchrow_array) {
if ($INET2 gt ' ') {
print "$Master_ID:\t\t$INET2\t\t($Master_Type)\n";
}
}

die $sth->errstr if ($sth->err);

$sth->finish;
$rc = $dbh->disconnect | | warn $dbh->errstr; # disconnect from the bad boy



dws
Deleted

Jun 26, 2000, 3:48 PM

Post #2 of 2 (542 views)
Re: null DB entries [In reply to] Can't Post

Let the database do the work for you.

SELECT *
FROM SY01200
WHERE INET2 IS NOT NULL



 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives