Anish Enos Mathew wrote:

        I want to insert 100 records into the database randomly. Here
"seq_number" is the primary key. Is there any method by which I can
check whether a randomly selected number which I am going to insert in
the database already exists in the database or not?
Anish,

You can simply do a select before the insert to see if your new primary key already exists. Since seq_number is a primary key, the query below will return either 0 if it doesn't exist, or 1 if it does.

 select count(*) from data_table where seq_number = :my_random_number;

Or you can just go ahead and execute the insert. You will get an error if you try to insert a record with a duplicate primary key. Catch the error, generate a new random number and try again.

HTH
Dennis Cote

Reply via email to