Mailing List
Home
Forum Home
MySQL General - General MySQL discussion
MySQL++ - Programming with the C++ API to MySQL
MaxDB - Everything about MaxDB, formerly known as SAP DB
ODBC - ODBC with the MySQL Connector/ODBC driver
MySQL on Win32 - Runing MySQL on Windows 9x/Me/NT/2000/XP
Java Help - Mostly related to the MySQL Connector/J driver
Perl - Perl support for MySQL with DBI and DBD::mysql
GUI - MySQL GUI Tools
Announcement
Subjects
Subject: mysql openssl Question
ERROR 1045: Access denied for user: 'root@localhost ' (Using
password: NO)
Update one field with more fields from another table
Subject: Getting Identity after INSERT
ERROR 2002: Can 't connect to local MySQL server through socket
mysql test 4 1 fails with the gis test
Subject: MySQL Cluster Software
Downgrade Mysql from 4 to 3 23
Mysql 4 0 Oracle Stored Procedure Trigger Conversion
Can 't access mysql after kernel upgrade
Executing MySQL Commands From Within C Program
Comparing and writing out BLOBS
Subject: Re: Preventing Duplicate Entries
FULLTEXT query format question
Strange behavior, Table Level Permission
Does the binary log enabling affect the MySQL performances?
mysql:it 's a db not a dbms how it 's possible?!
mysql have same function mthod as Oracle decode()
 
Subject: NULL values returning as empty string

Subject: NULL values returning as empty string

2007-10-23       - By Larry Low

 Back
I am unable to figure out why but NULL values which from what I read should
be undefined are being defined.  See the example below for the column
thold_hi which shows as NULL in the database but the reference
$row->{'thold_hi'} being defined.

I am running mysql 5.0.22 and DBI 1.58.

Example:

my $sql = "SELECT t.lastread,t.thold_hi,t.thold_low,thold_alert,bl_alert
FROM host h LEFT JOIN data_local dl ON h.id=dl.host_id LEFT JOIN
data_template_rrd dr ON dr.local_data_id=dl.id LEFT JOIN thold_data t ON
t.data_id=dr.id WHERE h.description='something' AND
dr.data_source_name='hdd_free'";

my $sth = $dbh->prepare($sql);
$sth->execute();
my $row = $sth->fetchrow_hasref();

if (!defined($row->{'thold_hi'})) {
  print "Not Defined\n";
} else {
  print "Defined\n";
}


mysql> SELECT t.lastread,t.thold_hi,t.thold_low,thold_alert,bl_alert FROM
host
h LEFT JOIN data_local dl ON h.id=dl.host_id LEFT JOIN data_template_rrd dr
ON
dr.local_data_id=dl.id LEFT JOIN thold_data t ON t.data_id=dr.id WHERE
h.description='something' AND dr.data_source_name='hdd_free';
+-- ---- --+-- ---- --+-- ---- ---+-- ---- -----+-- ---- --+
| lastread | thold_hi | thold_low | thold_alert | bl_alert |
+-- ---- --+-- ---- --+-- ---- ---+-- ---- -----+-- ---- --+
| 24997856 | NULL     | 25000000  |           1 |        0 |
+-- ---- --+-- ---- --+-- ---- ---+-- ---- -----+-- ---- --+
1 row in set (0.00 sec)


----
Larry Low
4150 N Drinkwater Blvd., 5th Floor
Scottsdale, AZ  85251
E-mail: llow@(protected)'

Telesphere Networks, Inc




--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe:    http://lists.mysql.com/perl?unsub=mysql@(protected)