Linux下Perl脚本运行的问题

各位大神,请教大家个问题,Linux环境下运行了perl基本,结果报这样的一个错:Can't locate object method "excute" via package "DBI::st" at perltest1.pl line 62.
是在搞不不明白是怎么回事啊,纠结了好几天了,麻烦大家帮我看看,谢谢了!
perl代码:
#!/usr/bin/perl
use DBI;

$ENV{ORACLE_SID}='orcl';
$ENV{ORACLE_BASE}='/data/oracle/product/11.2.0';
$ENV{ORACLE_HOME}='/data/oracle/product/11.2.0/db_1';
$ENV{LD_LIBRARY_PATH}='/data/oracle/product/11.2.0/db_1/lib';
$ENV{NLS_LANG}='american_america.ZHS16GBK';

$oracle_dsn='dbi:Oracle:host=10.51.176.51;sid=orcl;port=1521';
$oracle_user='system';
$oracle_pwd='system123';

sub connect_apc_db {
$dbh_oracle = DBI->connect( $oracle_dsn, $oracle_user, $oracle_pwd ) or die $DBI::errstr;
$dbh_oracle->{ChopBlanks} = 1;
}

sub disconnect_apc_db {
$dbh_oracle->disconnect or die $DBI::errstr;
}

sub Now{
my ($Ts,$Tm,$Th,$TD,$TM,$TY,$Tw,$Td,$Ti) = localtime;

$nowTime_s = sprintf "%04d-%02d-%02d %02d:%02d:%02d", $TY+1900,$TM+1,$TD,$Th,$Tm,$Ts;

}

my $logfile="/package_rtspc/master/logfile.log";

sub Logf {

my $Logmsg = shift;

&Now;
open LOG, ">> $logfile" || die "Can't open the logfile : $logfile";
flock LOG, 2; #To Lock the logfile

print LOG "$nowTime_s $Logmsg\n";
flock LOG, 0; #Unlock the logfile
close LOG;

}

my $ins_sqlstr="insert into apcs.APCS_USER
(user_no, group_id, cat, password, upd_man, upd_date)
values
(?, ?, ?, ?, ?, ?)";

sub select_userno
{
my $sel_hruserno="select max(t1.user_no) from apcs.hr_user t1";
my $sth=$dbh_oracle->prepare(qq($sel_hruserno));
$sth->excute();
my $errorstring=$sth->errstr;
if(defined($errorstring))
{
Logf("select max(t1.user_no) from hr_user t1---ERROR:$errorstring");
}
}

说明:应该是执行到$sth->excute();语句时报的错,麻烦各位帮我看下,谢谢了!

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐