Operating System - HP-UX
1823750 Members
3798 Online
109664 Solutions
New Discussion юеВ

Autocommit Off in Oracle + Perl

 
network_4
Advisor

Autocommit Off in Oracle + Perl

Hi, Anyone having idea how to disable autocommit while executing query with perl. I am using oracle 9i and perl 5.8 but when ever i execute any update query it autocommit.
++++++++++++++++++++++ Below is wht i am doing for disabling it +++++++++++++++==
#!/Opt/perl64/bin/perl
use DBI;
$dbh = DBI->connect('DBI:Oracle:iobastst','nidhitabs','nidhitabs',{AutoCommit => 0}) or die "Couldn't connect to database: " . DBI->errstr;
$dbh->{AutoCommit} = 0;
$sth = $dbh->prepare("nsert into cams_file_mv_status values ('$data1','$!','$data')") or die "Couldn't prepare statement: " . $dbh->errstr;) or die "Couldn't prepare statement: " . $dbh->errstr;
$sth->execute();
4 REPLIES 4
H.Merijn Brand (procura
Honored Contributor

Re: Autocommit Off in Oracle + Perl

Except for some typo's (/Opt -> /opt and "nsert => "insert), I don't see anything wrong. What is the error you get?
Here is how I would have written it:

#!/opt/perl64/bin/perl
use strict;
use warnings;
use DBI;
my $dbh = DBI->connect ("DBI:Oracle:iobastst", "nidhitabs", "nidhitabs", {
AutoCommit => 0,
RaiseError => 1,
PrintError => 1,
}) or die "Couldn't connect to database: $DBI::errstr";
my $sth = $dbh->prepare ("insert into cams_file_mv_status values (?, ?, ?);
$sth->execute ($data1, $!, $data);
$sth->finish;
$dbh->commit;

Use RaiseError and PrintError to get the details of all failures.
If things still fail, use DBI->trace (9) or alike.
I hope the username/password combo is fake, otherwise I would/could ask a moderator to edit this thread to change those.

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
network_4
Advisor

Re: Autocommit Off in Oracle + Perl

Hi, Its not giving any error but when i am checking same thru toad its showing me value that means autocommit is on
network_4
Advisor

Re: Autocommit Off in Oracle + Perl

Hi it has the right value for autocommit during execution of the program but still it is commiting it:

$ /opt/perl64/bin/perl phase1a.pl
outside while : 0
inside while and for : 0
no update : 0
inside sec while and for : 0
No such file or directory
inside else : 0
before sth2->finish : 0
before sth1->finish : 0
inside while and for : 0
no update : 0
inside sec while and for : 0
inside else : 0
before sth2->finish : 0
before sth1->finish : 0
before sth->finish : 0
after sth->finish : 0
after dis->finish : 0


Where can be the problem
network_4
Advisor

Re: Autocommit Off in Oracle + Perl

Hi, Can anyone help me how to disable autocommit.