On Jun 20, 2:23 pm, [EMAIL PROTECTED] (Aruna Goke) wrote: > Can someone put me thru this? > > when I run the script..it bring no error..
That's because you never asked it to give you any errors. That's something of a Perl trait - it generally doesn't tell you anything's wrong unless you ask it to tell you. > however, the table radacct is not updated. > > what have i done wrong. > > $dbh = DBI->connect($data_source, $user, $pass); You should pass a fourth argument to connect(). That argument is a reference to a hash of the options you'd like to enable. Specifically, you should enable RaiseError, which tells DBI to die with an error any time there's a database error. So: my $dbh = DBI->connect( $data_source, $user, $pass, { RaiseError => 1 } ); (I also usually recomment specifying AutoCommit as either 0 or 1, depending on if you want the database to commit after every insert/ update/delete, because the default can change between different database systems, different versions of the database, and different versions of DBD::*) > $sql = "UPDATE radacct SET AcctSessionTime = ?, TrunkIdOut = ?, > TrunkIdIn = ? where AcctUniqueId = ?"; > $sth = $dbh->prepare($sql); Because you've now enabled RaiseError, if prepare() has an error, Perl will now exit with an error. If you don't enable RaiseError, you must check prepare() explicitly: my $sth = $dbh->prepare($sql) or die "Error preparing <<$sql>>: $DBI::errstr"; > #split the file into variables > @x =(split/,/)[0,1,2,3,4,5,6]; my @x = (split /,/)[0..6]; or my @x; @x[0..6] = split /,/; > $sth->execute($x[2], $x[5], $x[4], $x[6]); $sth->execute(@x[2,5,4,6]); And, again, if you don't enable RaiseError, you must check execute() for errors explicitly: $sth->execute(@x[2,5,4,6]) or die "Error executing <<$sth->{Statement}>> with values @x[2,5,4,6]: $DBI::errstr"; This might not be necessary for the RDMS you use, but I generally end my database-driven scripts with this block: END { if ($?) { print "Exiting with error, rolling back data!\n"; $dbh->rollback(); } else { print "Exiting successfully, committing data\n"; $dbh->commit(); } $dbh->disconnect(); } Hope this helps, Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/