By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,084 Members | 1,956 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,084 IT Pros & Developers. It's quick & easy.

Prevent duplicate entry

P: 9
I have a unique constraint in my Oracle table for 3 fields. If I enter duplicate info on the table using Oracle client I will get an Ora message error ORA-00001 that tells me it is a duplicate entry attempt.

How do I capture that in my PHP page if someone tries to enter duplicate record info?

My PHP Oracle insert statement in the action page:

Expand|Select|Wrap|Line Numbers
  1. $s = OCIParse($c, "insert into tableOne values ('$varOne', '$varTwo', '$varThree')");
  2. OCIExecute($s, OCI_DEFAULT);
How would I capture the ORA-00001 unique constraint message to prevent a duplicate entry into the Oracle table?
Dec 21 '07 #1
Share this Question
Share on Google+
1 Reply


Ranjan kumar Barik
P: 95
I have a unique constraint in my Oracle table for 3 fields. If I enter duplicate info on the table using Oracle client I will get an Ora message error ORA-00001 that tells me it is a duplicate entry attempt.

How do I capture that in my PHP page if someone tries to enter duplicate record info?

My PHP Oracle insert statement in the action page:

Expand|Select|Wrap|Line Numbers
  1. $s = OCIParse($c, "insert into tableOne values ('$varOne', '$varTwo', '$varThree')");
  2. OCIExecute($s, OCI_DEFAULT);
How would I capture the ORA-00001 unique constraint message to prevent a duplicate entry into the Oracle table?
Hi,
You can do one thing.
First get the all the values you have in the respective column.
Then compare it with the inserted value and if there is no matching then execute the insert statement.
else Display an error message to the user.

Happy Programming!
:)
Dec 21 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.