Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

On error DBI mysql

Status
Not open for further replies.

skosterow

Technical User
Feb 23, 2002
135
US
heya Guys and Gals!

I need just alittle help.....

i would like to exit out to an error page if perl detects a duplicate record.

heres my script:

my $dsn = "DBI:mysqlPP:TTC:$DB::SERVER";
my $dbh = DBI->connect($dsn, $DB::USER, $DB::pASS);

my $sth = $dbh->prepare(qq{
INSERT INTO caller
VALUES ('$TT::CALLINBY', '$TT::CALLLOCATION', '$TT::CALLPHONE', '$TT::CALLEMAIL')
});

$sth->execute();

if (ERROR EXISTS) { DO THIS }

$sth->finish();
$dbh->disconnect();

Im not quite sure how i could pull the error message then act on it. Here is the error i get:

DBD::mysqlPP::st execute failed: Duplicate entry 'Gary Freeman' for key 1 at C:\create.pl line 226.

Thanks in advanced!

- Scott
 
okay i was thinking to do that, however wouldnt that effect the tiume it takes if there is ALOT of data in the table?

also, Sleipnir214, im not quite sure how you mean search the key.... is there an easy way to do that? that wont take alot of server time?

- Scott
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top