MySQL Forums
Forum List  »  Perl

QUERY perl DBI versus mysql - different results
Posted by: John Ackley
Date: February 24, 2010 12:52PM

different results perl versus mysql command line

DBI output ----------
mysql> select ifPhysAddress from interfaces where id = '00:20:A6:56:55:2A';

+-------------------+
| ifPhysAddress |
+-------------------+
| 00:20:A6:56:55:2A |
| |
| 00:30:F1:9B:33:5A |
+-------------------+
3 rows in set (0.00 sec

perl DBI output -------------------
[john@scan updatenodes]$ ./fix.pl
00:20:A6:56:55:2A
[john@scan updatenodes]$

code -------------------------------

#! /usr/bin/perl -w
use strict;
use DBI;
my $driver = DBI->install_driver('mysql') or die;
my $NETWORK = DBI->connect('DBI:mysql:database=network','xxxx','xxxxxxx')
or die;
my $MAC = $NETWORK->prepare(qq{SELECT ifPhysAddress FROM interfaces WHERE id = "00:20:A6:56:55:2A"})
or die;
$MAC->execute;
while(my $key = $MAC->fetchrow_array) {
printf "%15s\n",$key;
}

supporting information -----------------------------
interfaces | CREATE TABLE `interfaces` (
`id` char(17) NOT NULL,
`ifIndex` int(10) unsigned NOT NULL default '0',
`ifPhysAddress` char(17) default NULL,
`ifDescr` text,
`ifType` smallint(5) unsigned default NULL,
`ifAdminStatus` smallint(5) unsigned default NULL,
`ifOperStatus` smallint(5) unsigned default NULL,
`ifMediaType` smallint(5) unsigned default NULL,
`ssid` text,
PRIMARY KEY (`id`,`ifIndex`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1

data set
mysql> select * from interfaces where id = '00:20:A6:56:55:2A' \G
*************************** 1. row ***************************
id: 00:20:A6:56:55:2A
ifIndex: 1
ifPhysAddress: 00:20:A6:56:55:2A
ifDescr: Ethernet Interface
ifType: 6
ifAdminStatus: 1
ifOperStatus: 1
ifMediaType: NULL
ssid: NULL
*************************** 2. row ***************************
id: 00:20:A6:56:55:2A
ifIndex: 2
ifPhysAddress:
ifDescr: lo0
ifType: 24
ifAdminStatus: 1
ifOperStatus: 1
ifMediaType: NULL
ssid: NULL
*************************** 3. row ***************************
id: 00:20:A6:56:55:2A
ifIndex: 3
ifPhysAddress: 00:30:F1:9B:33:5A
ifDescr: WORP Interface
ifType: 6
ifAdminStatus: 1
ifOperStatus: 1
ifMediaType: NULL
ssid: NULL
3 rows in set (0.00 sec)

Options: ReplyQuote


Subject
Written By
Posted
QUERY perl DBI versus mysql - different results
February 24, 2010 12:52PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.