Home » Developer & Programmer » Forms » prevent duplicate record entry date wise (Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production, WINSRV 2003)
prevent duplicate record entry date wise [message #526250] Mon, 10 October 2011 05:54 Go to next message
hissam78
Messages: 193
Registered: August 2011
Location: PAKISTAN
Senior Member
we have a table attendance_d with no constraint which have duplicate emp_id we want to stop duplicate emp_id on the same date. if employee's record already entered in today's date then duplicate Error message must show if he tries again to enter the same record.
for this i have written the following code but it is not working date wise some body can help me. i want to use on WHEN VALIDATE ITEM TRIGGER in oracle forms 6i.

Code:
DECLARE
l_count NUMBER;
BEGIN
SELECT COUNT (*)
INTO l_count
FROM attendance_d
WHERE emp_id = :attendance_d.emp_id AND attendance_date = SYSDATE;
IF l_count > 0
THEN
MESSAGE ('Duplicate Value!');
MESSAGE (' ', no_acknowledge);
RAISE form_trigger_failure;
ELSE
NULL;
END IF;
END;

please help me.

Sorry dear all i have tried my best to format the syntax of code but in preview it showing like as above i have formated in toad by using the key ctrl+shift+f.

thanx

shafiq
Re: prevent duplicate record entry date wise [message #526252 is a reply to message #526250] Mon, 10 October 2011 06:04 Go to previous messageGo to next message
Littlefoot
Messages: 21817
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
A reason might be the fact that SYSDATE contains both date and time components, so it is not very likely that your "attendance_date" will be equal to SYSDATE itself. Perhaps you should try with
and attendance_date = trunc(sysdate)
(or some other combination, depending on what "attendance_date" really contains.

As of formatting your code, it is described here.
Re: prevent duplicate record entry date wise [message #526256 is a reply to message #526252] Mon, 10 October 2011 06:10 Go to previous message
hissam78
Messages: 193
Registered: August 2011
Location: PAKISTAN
Senior Member
thanx little foot
problem resolved.

shafiq
Previous Topic: when i press exit button the message shown " Do you want to save the changes you have made &quo
Next Topic: LOV dynamic automatic filtering
Goto Forum:
  


Current Time: Sun Aug 11 10:42:24 CDT 2024