1

Getting something is wrong with the execute statement. It just seems to hang forever when I run in command prompt. It doesn't die either. does execute maybe need parameters?

#!/usr/bin/perl
use DBI;
use Data::Dumper;

$dbh = DBI->connect('DB', 'NAME', 'PASS',{ LongReadLen => 1000000} ) or die 'Error: cant connect to db';

$st= "update table set the_id = 7 where mid = 23 and tid = 22";

my $UpdateRecord = $dbh->prepare($st)  or die "Couldn't prepare statement: $st".$dbh->errstr;
$UpdateRecord->execute() or die "can not execute $UpdateRecord".$dbh->errstr;
$UpdateRecord->finish;


$dbh->disconnect();

EDIT:
I tried binding in execute as well as using bind_param(), and it's still hanging up.

4

2 回答 2

0

问题是我锁定了一堆对象,因为在我运行一次之前未能断开连接......是的,不要那样做。

于 2013-03-27T17:12:40.063 回答
0

你需要一个do而不是prepare.

my $UpdatedRecord = $dbh->do($st)  or die "Statement fails: $st".$dbh->errstr;

来自 DBI

此方法通常对于无法提前准备(由于驱动程序的限制)或不需要重复执行的非 SELECT 语句最有用。它不应该用于 SELECT 语句,因为它不返回语句句柄(因此您无法获取任何数据)。

此外,在声明的顶部添加/使用您正在使用的数据库驱动程序模块总是更好use DBI;

use DBD::Oracle;

还添加

使用严格;
使用警告;

于 2013-03-27T10:51:17.330 回答