我尝试使用此脚本从DB获取一些信息:
use strict;
use warnings;
use DBI;
my $dbh;
my $query= "SELECT table_name FROM user_tables";
my $queryH;
my @tables_names;
my $i;
my $db_pass2 = "*****";
my $db_user2 = "*****";
print "DB connection...\n\n";
#DB connection
$dbh = DBI->connect('DBI:Oracle:host=***********;sid=*****;port=***', $db_user2, $db_pass2);
$queryH = $dbh->prepare($query);
print " ".$queryH->execute()."\n";
print "\n\n";
$queryH->finish();
$dbh->disconnect();
print "\n\n End!!!\n";
为什么$queryH->execute()
会给我0E0?我怎样才能得到一个字符串作为结果?
我需要从db获取表名...如何使用此脚本获取它?
答案 0 :(得分:3)
execute
仅执行查询。要检索结果,您必须使用Statement Handle Methods中记录的众多检索方法之一。例如:
$queryH->execute;
my ( $table_name ) = $queryH->fetchrow_array;
print "result = $table_name\n";