How about using a convenience method, 

$nm = $dbh->selectrow_array(q[select global_name from global_name]);

print "\nThe instance is $nm\n" if $nm;

On Fri, 2004-04-30 at 05:47, Srikanth Madani wrote:
> TMTOWTDI and all that :-) - but please do correct me if this code is
> inappropriate in some way:
> 
> #Assuming that the database handle $dbh is successfully defined.
> my $sth = $dbh->prepare ('SELECT global_name FROM global_name') || die
> "\n$0: Failed to prepare SQL statement: $dbh->errstr\n";
> $sth->execute() || die "\n$0: Failed to execute SQL query: $sth->errstr\n";
> my @data = $sth->fetchrow_array();
> if ($sth->rows == 0) {
>         print "\nNo rows returned - Ok, so that didn't really work!.\n";
> } else {
>       print "\nThe instance is @data\n";
> }
> 
> 
> Cheers,
> 
> Srikanth Madani

Reply via email to