Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-01-2009, 03:44 AM   #1
Registered: Mar 2008
Posts: 58

Rep: Reputation: 15
Perl DBI script - No output from program

Hi All,
I've the following code, for reading data from a oracle database table and displaying the columns, but it is not showing any output after excuting, not showing any error also, can anyone guide me where am i making mistake?

use warnings;
use strict;
use DBI;

my $dbh = DBI->connect('DBI:Oracle:EQPARA', 'sun', 'sunpswd')
                or die "Couldn't connect to database: " . DBI->errstr;

my $sql = qq { SELECT magnitude, phases, depth FROM eqtest };
my $sth = $dbh->prepare ( $sql );

my ($magnitude, $phases, $depth );
$sth->bind_columns(undef, \$magnitude, \$phases, \$depth);

while ($sth->fetch()) {
print "$magnitude, $phases, $depth\n";

Old 09-02-2009, 01:05 AM   #2
LQ Newbie
Registered: Nov 2008
Posts: 13

Rep: Reputation: 3
I don't know if it makes a difference, but I've always called DBI in this format:

my $dbh = DBI->connect('DBI:Oracle:EQPARA', 'sun', 'sunpswd')
or die "Couldn't connect to database: ", $DBI::errstr;
$dbh->{RaiseError} = 1; # Die if future queries result in an error

Silly question, but are you sure the table has data? Perhaps add these lines after the $sth->execute(); to verify:

my $nf = $sth->{NUM_OF_FIELDS};
print "This query returned $nf fields\n";
Old 09-02-2009, 05:53 AM   #3
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
Y are you binding the columns,

simple iterate over sth

while(my $ref = $sth->fetchrow_hashref)
  print qq[$ref->{magnitude}, $ref->{phases}, $ref->{depth}];


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
perl dbi:mysql shows error syntax error dbi:mysql ?? haxpak Linux - Server 4 02-27-2009 12:09 AM
perl dbi module error "error at dbi:" dbi-> connect statement mysql haxpak Linux - Newbie 1 02-25-2009 09:22 AM
LXer: Managing Swatch Output With Yet Another Perl Script LXer Syndicated Linux News 0 12-08-2008 06:41 AM
Authentication failing in Perl DBI script resetreset Programming 4 11-19-2008 10:01 AM
Error using DBI with Perl bostonantifan Ubuntu 0 11-11-2007 02:47 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:04 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration