Updating NOT inserting [message #578690] |
Mon, 04 March 2013 04:06 |
|
nada_am
Messages: 9 Registered: January 2013 Location: KSA
|
Junior Member |
|
|
Hi
I have a form that used to enter new employees , if the employee ID already registerd then the user can ONLY update the information and NOT adding the same ID with new info.
int the ID item in when-validat-item trigger I put this code
begin
IF :SOURCE_CODE IS NULL THEN MESSAGE('PLEASE ENTER SOURCE CODE');
ELSE
declare --chg#13-3169 nada
l_count NUMBER;
BEGIN
SELECT COUNT (*)
INTO l_count
FROM source_master
WHERE SOURCE_CODE= :SOURCE_CODE;
IF l_count > 0
THEN
msg_alert('This emp is exist and contract end date is ' || :con_end_date);
Set_Item_Property('emp.con_end_date',UPDATE_ALLOWED,PROPERTY_FALSE);
Set_Item_Property('emp..con_start_date',UPDATE_ALLOWED,PROPERTY_FALSE);
Set_Item_Property('emp..source_name',UPDATE_ALLOWED,PROPERTY_FALSE);
Set_Item_Property('emp..contract_type',UPDATE_ALLOWED,PROPERTY_FALSE);
ELSE
null;
END IF;
END;
END IF;
end;
in the save button the code is : commit;
The problem Is : a new record with same ID is inserted every time !! Duplication is happining
please help me
|
|
|
|
|
|
|
|
Re: Updating NOT inserting [message #578697 is a reply to message #578696] |
Mon, 04 March 2013 04:53 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
It means that primary key consists of several columns (i.e. it is a composite key), not only employee ID. (Or, if it is not a primary key, then it might be unique key or index).
What you described is perfectly OK, as far as Oracle is concerned. Now, it depends on you what restriction YOU want to apply. If you want to have unique ID values, then create unique index on ID column. It means that you'll have
- primary key on ID, NAME, DOB
- unique index on ID
Note that the above terminology might differ from the actual situation you have; I don't know what it is because you didn't post CREATE TABLE statement (which would include constraints and indexes as well).
|
|
|