I'm not sure what is causing the problem in your case, but I have afew comments.
1. Use Oracle sequences for the unique key unless you have a good reason not to. What you are trying to do is already built into Oracle, no need to invent your own way to do it. [In Oracle SQL*Plus or other tool] // Change options and sequence name as needed. Create Sequence SQ_MySequence Increment By 1 Start WIth 1 MaxValue 10000000 MinValue 1 NoCycle Cache 20 NoOrder Then in Perl... my $sth = $dbh->prepare("Insert Into TABLE (keyfield,val1,val2) Values (SQ_MySequence.NextVal,?,?)"); 2. Make sure you lock the file! If there is a possiblity that two instances of the script will be accessing the file at the same time you need to lock the table to prevent this. See perldoc -f flock Rob -----Original Message----- From: Mark Martin [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 15, 2002 12:30 PM To: [EMAIL PROTECTED] Subject: UNIQUE KEY Hi, I'm trying to maintain a unique key in an Oracle Table while working on the table using DBI. the unique key is just a no. read in from a txt file and incremented for each record - supposedly. In fact I'm getting unique constraint violation. Can anybody tell me what is wrong with this code,(the statement handler inserts into the table) cheers, Mark if (condition){ open (IN,$uniquefile) or die "Cannot Open $uniquefile \n"; $uniquemarker=<IN>; close(IN); $uniquemarker++; $sth1->execute($uniquemarker,$var1,$var2) or die "Can't execute SQL statement: $DBI::errstr\n"; } open (OUT,">$uniquefile"); print OUT "$uniquemarker"; $dbh1->disconnect(); exit; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]