On 11/24/2004 06:19 AM, Mark Martin said:

I have a very simple script to delete records from an Oracle table :

#!/usr/bin/perl

use DBI;
use DBD::Oracle;

$dbh = DBI->connect( "dbi:Oracle:database", "user", "password") or die "Can't connect to Oracle database: $DBI::errstr\n";

$dbh->do( "DELETE FROM TABLE WHERE YEAR=2003" );

exit;

the script never finishes and the records remain????

If that is the actual SQL, TABLE is a reserved word so it would need to be "TABLE".


You have no idea what happened because you aren't checking for errors in do(). The examples below show some ways (only one is needed), see http://search.cpan.org/~timb/DBI-1.46/DBI.pm for more information; search for errstr, RaiseError and PrintError.

  $dbh = DBI->connect( "dbi:Oracle:database", "user", "password",
    { RaiseError => 1 } )
    or die "Can't connect to Oracle database: $DBI::errstr\n";
  $dbh -> {RaiseError} = 1;

  $dbh->do( qq(DELETE FROM "TABLE" WHERE YEAR=2003) )
    or die "Can't delete, $DBI::errstr\n";

--
Mac :})
** I usually forward private questions to the appropriate mail list. **
Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html
Cthulhu in 2004.  Don't settle for the lesser evil.

Reply via email to