Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Reaped: Perl DBI NULL and undef

by NodeReaper (Curate)
on Aug 22, 2012 at 01:04 UTC ( #988918=perlquestion: print w/ replies, xml ) Need Help??
NodeReaper has asked for the wisdom of the Perl Monks concerning the following question:

This node was taken out by the NodeReaper on Aug 22, 2012 at 04:27 UTC
Reason: [Old_Gray_Bear]: Reap: Dup of 988914

You may view the original node and the consideration vote tally.

Comment on Reaped: Perl DBI NULL and undef
Re: Perl DBI NULL and undef
by Marshall (Prior) on Aug 22, 2012 at 02:38 UTC
    my $sth = $dbh->prepare("select NAME from data_template_data"); my $results = $sth->execute() or die "execute failed"; # the return value from $sth->execute() will be undef # if the query failed...otherwise the $results value # will contain the number of lines in that result set # # The DBI will return "0E0" to mean a true value with # a numeric result of "zero" to differentiate between # "didn't work" (undef) and "worked, but returned no rows" # this is the "logically true, but numeric false value". #To get the rows, use a while() loop.. # while ( (my $name) = $sth->fetchrow()) { print "name is $name\n"; }
    I don't know the schema for your DB. But in general, you will get a NULL for for a blank field instead of undef, but there are exceptions. There are "rules" for the fields that are specified when the table is created.

    If you can give me some data, I can create a MySQL DB on my server and help you further.
    Don't go "crazy", just give me 5-10 lines or so.

      INSERT INTO data_template_data (id, local_data_template_data_id, local +_data_id, data_template_id, data_input_id, t_name, name, name_cache, +data_source_path, t_active, active, t_rrd_step, rrd_step, t_rra_id) V +ALUES (3, 0, 0, 3, 2, 'on', '|host_description| - Hard Drive Space', '', N +ULL, '', 'on', '', 300, ''), (4, 0, 0, 4, 1, '', '|host_description| - CPU Usage - System', '', N +ULL, '', 'on', '', 300, ''), (5, 0, 0, 5, 1, '', '|host_description| - CPU Usage - User', '', NUL +L, '', 'on', '', 300, ''), (6, 0, 0, 6, 1, '', '|host_description| - CPU Usage - Nice', '', NUL +L, '', 'on', '', 300, ''), (7, 0, 0, 7, 2, 'on', '|host_description| - Noise Level', '', NULL, +'', 'on', '', 300, ''), (8, 0, 0, 8, 2, 'on', '|host_description| - Signal Level', '', NULL, + '', 'on', '', 300, ''), (9, 0, 0, 9, 2, 'on', '|host_description| - Wireless Transmits', '', + NULL, '', 'on', '', 300, ''), (10, 0, 0, 10, 2, 'on', '|host_description| - Wireless Re-Transmits' +, '', NULL, '', 'on', '', 300, ''), (11, 0, 0, 11, 4, '', '|host_description| - Load Average', '', NULL, + '', 'on', '', 300, ''), (13, 0, 0, 13, 6, '', '|host_description| - Memory - Free', '', NULL +, '', 'on', '', 300, ''), (15, 0, 0, 15, 6, '', '|host_description| - Memory - Free Swap', '', + NULL, '', 'on', '', 300, ''), (16, 0, 0, 16, 7, '', '|host_description| - Processes', '', NULL, '' +, 'on', '', 300, ''), (17, 0, 0, 17, 5, '', '|host_description| - Logged in Users', '', NU +LL, '', 'on', '', 300, ''), (18, 0, 0, 18, 10, '', '|host_description| - Ping Host', '', NULL, ' +', 'on', '', 300, ''), (19, 0, 0, 19, 1, '', '|host_description| - Total Users', '', NULL, +'', 'on', '', 300, ''), (20, 0, 0, 20, 1, '', '|host_description| - Total Logins', '', NULL, + '', 'on', '', 300, ''), (22, 0, 0, 22, 1, '', '|host_description| - File System Reads', '', +NULL, '', 'on', '', 300, ''), (23, 0, 0, 23, 1, '', '|host_description| - File System Writes', '', + NULL, '', 'on', '', 300, ''), (24, 0, 0, 24, 1, '', '|host_description| - Cache Checks', '', NULL, + '', 'on', '', 300, ''), (25, 0, 0, 25, 1, '', '|host_description| - Cache Hits', '', NULL, ' +', 'on', '', 300, ''), (26, 0, 0, 26, 1, '', '|host_description| - Open Files', '', NULL, ' +', 'on', '', 300, ''), (27, 0, 0, 27, 1, '', '|host_description| - 5 Minute CPU', '', NULL, + '', 'on', '', 300, ''), (30, 0, 0, 30, 1, '', '|host_description| - Load Average - 1 Minute' +, '', NULL, '', 'on', '', 300, ''), (31, 0, 0, 31, 1, '', '|host_description| - Load Average - 5 Minute' +, '', NULL, '', 'on', '', 300, ''), (32, 0, 0, 32, 1, '', '|host_description| - Load Average - 15 Minute +', '', NULL, '', 'on', '', 300, ''), (33, 0, 0, 33, 1, '', '|host_description| - Memory - Buffers', '', N +ULL, '', 'on', '', 300, ''), (34, 0, 0, 34, 1, '', '|host_description| - Memory - Free', '', NULL +, '', 'on', '', 300, ''), (35, 0, 0, 35, 2, 'on', '|host_description| - Volumes', '', NULL, '' +, 'on', '', 300, ''), (36, 0, 0, 36, 2, 'on', '|host_description| - Directory Entries', '' +, NULL, '', 'on', '', 300, ''), (37, 0, 0, 37, 11, 'on', '|host_description| - Hard Drive Space', '' +, NULL, '', 'on', '', 300, ''), (38, 0, 0, 38, 2, 'on', '|host_description| - Errors/Discards', '', +NULL, '', 'on', '', 300, ''), (39, 0, 0, 39, 2, 'on', '|host_description| - Unicast Packets', '', +NULL, '', 'on', '', 300, ''), (40, 0, 0, 40, 2, 'on', '|host_description| - Non-Unicast Packets', +'', NULL, '', 'on', '', 300, ''), (41, 0, 0, 41, 2, 'on', '|host_description| - Traffic', '', NULL, '' +, 'on', '', 300, ''), (55, 0, 0, 42, 2, '', '|host_description| - CPU Utilization', '', NU +LL, '', 'on', '', 300, ''), (56, 0, 0, 43, 12, '', '|host_description| - Hard Drive Space', '', +NULL, '', 'on', '', 300, ''), (57, 0, 0, 44, 12, '', '|host_description| - CPU Utilization', '', N +ULL, '', 'on', '', 300, ''), (58, 0, 0, 45, 1, '', '|host_description| - Processes', '', NULL, '' +, 'on', '', 300, ''), (59, 0, 0, 46, 1, '', '|host_description| - Logged in Users', '', NU +LL, '', 'on', '', 300, ''), (62, 13, 3, 13, 6, NULL, '|host_description| - Memory - Free', 'Loca +lhost - Memory - Free', '<path_rra>/localhost_mem_buffers_3.rrd', NUL +L, 'on', NULL, 300, NULL), (63, 15, 4, 15, 6, NULL, '|host_description| - Memory - Free Swap', +'Localhost - Memory - Free Swap', '<path_rra>/localhost_mem_swap_4.rr +d', NULL, 'on', NULL, 300, NULL), (64, 11, 5, 11, 4, NULL, '|host_description| - Load Average', 'Local +host - Load Average', '<path_rra>/localhost_load_1min_5.rrd', NULL, ' +on', NULL, 300, NULL), (65, 17, 6, 17, 5, NULL, '|host_description| - Logged in Users', 'Lo +calhost - Logged in Users', '<path_rra>/localhost_users_6.rrd', NULL, + 'on', NULL, 300, NULL), (66, 16, 7, 16, 7, NULL, '|host_description| - Processes', 'Localhos +t - Processes', '<path_rra>/localhost_proc_7.rrd', NULL, 'on', NULL, +300, NULL), (68, 0, 0, 47, 1, '', '|host_description| - Memory - Cache', '', NUL +L, '', 'on', '', 300, ''), (69, 0, 0, 48, 1, 'on', '|host_description| -', '', NULL, '', 'on', +'', 300, ''), (70, 0, 0, 49, 0, '', '10 minutes', '', NULL, '', 'on', '', 600, '') +, (71, 70, 8, 49, 0, NULL, '10 minutes', '10 minutes', '/var/www/cacti +_rrd/MMS/Daily/CDR_TOTAL_901S902M905S906WAPENC.rrd', NULL, 'on', NULL +, 600, NULL), (72, 70, 9, 49, 0, NULL, '10 minutes', '10 minutes', '/var/www/cacti +_rrd/MMS/Daily/CDR_TOTAL_901R902M905S906FOREIGNOPTUS.rrd', NULL, 'on' +, NULL, 600, NULL);

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2014-07-31 17:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (249 votes), past polls