Avoid Duplication in three tables [message #576055] |
Thu, 31 January 2013 03:36 |
|
nada_am
Messages: 9 Registered: January 2013 Location: KSA
|
Junior Member |
|
|
Dear all,
I'm creating oracle form to allow the user to register a new record in a table, I want to check the duplication in Four tables!
which means, the user is able to save the record if it's NOT already registered in the other four tables.By checking P_ID (user parameter).
this is my code:
Declare
v_count number;
begin
select count(*) into v_count ---Checking the 1st table
from 1_table
where p1_id=:p_id;
if (v_count>0) then
message ('Duplicate');
RAISE form_trigger_failure;
ELSE
select count(*) into v_count -------checking the 2nd table
from 2_table
where p2_id=:p_id;
if (v_count>0) then
message ('Duplicate');
RAISE form_trigger_failure;
ELSE
select count(*) into v_count ----checking the 3rd table
from 3_table
where 31_id=:p_id;
if (v_count>0) then
message ('Duplicate');
RAISE form_trigger_failure;
else
select count(*) into v_count --------checking the 4th table
from 4_table
where p4_id=:p_id;
if (v_count>0) then
message ('Duplicate');
RAISE form_trigger_failure;
end if;
end if;
end if;
end if;
END;
IS it correct ? please help me I'm confused ,,,thank you in advance
|
|
|
|
|
|
|