Is there a reason for doing it this way?  The main problem that might come
up here is if more than one instance of this script could run at close to
the same time.  If this gets kicked of by some random(ish) event, like a
user signing in or something, then you can have several scripts read the
number before the file gets updated.  Is there a reason not to use an Oracle
sequence?  That's the way I've done this type of thing in the past.  A
sequence will guarantee that only one copy of that number is available and
will automatically increment it for you.  I'll bet you can find out more at
http://technet.oracle.com

Good luck,
Peter C.

-----Original Message-----
From: Mark Martin [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 15, 2002 9:30 AM
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]

Reply via email to