Can we use RAISE FORM_FAILURE_TRIGGER in EXCEPTION [message #557336] |
Tue, 12 June 2012 00:44 |
mvmkandan
Messages: 68 Registered: May 2010 Location: Trivendrum
|
Member |
|
|
My requirement, if there is no record in emp table when validate the EMP_NO_CHK text field, i need to set the focus on that field (EMP_NO_CHK) itself.
But while execute the following code, I got error. Please suggest me anyone to achieve the task.
--EMP_NO_CHK_WHEN_VALIDATE_ITEM Trigger
-----------------------------------
Declare
cursor c is Select * from emp where Emp_no = :header.empno;
c1 emp%rowtype;
n NUMBER;
BEGIN
OPEN c;
Loop
FETCH c into C1;
Exit when c%notfound;
n := n + 1;
END LOOP:
CLOSE c;
If n = 0 then
Raise NO_DATA_FOUND;
END IF;
Exception
WHEN NO_DATA_FOUND THEN
RAISE FORM_FAILURE_TRIGGER;
WHEN OTHERS THEN
Message('asasdsad');
END;
Thanks in Advance,
Veera
|
|
|
|
Re: Can we use RAISE FORM_FAILURE_TRIGGER in EXCEPTION [message #557369 is a reply to message #557342] |
Tue, 12 June 2012 03:19 |
mvmkandan
Messages: 68 Registered: May 2010 Location: Trivendrum
|
Member |
|
|
oh sorry...
My requirement, if there is no record in emp table when validate the EMP_NO_CHK text field, i need to set the focus on that field (EMP_NO_CHK) itself.
But while execute the following code, I got error. Please suggest me anyone to achieve the task.
--EMP_NO_CHK_WHEN_VALIDATE_ITEM Trigger
-----------------------------------
Declare
cursor c is Select * from emp where Emp_no = :header.empno;
c1 emp%rowtype;
n NUMBER;
BEGIN
OPEN c;
Loop
FETCH c into C1;
Exit when c%notfound;
n := n + 1;
END LOOP:
CLOSE c;
If n = 0 then
Raise NO_DATA_FOUND;
END IF;
Exception
WHEN NO_DATA_FOUND THEN
RAISE FORM_TRIGGER_FAILURE;
WHEN OTHERS THEN
Message('asasdsad');
END;
Thanks in Advance,
Veera
|
|
|
Re: Can we use RAISE FORM_FAILURE_TRIGGER in EXCEPTION [message #557379 is a reply to message #557369] |
Tue, 12 June 2012 06:23 |
sandeepgujje
Messages: 28 Registered: January 2012 Location: India
|
Junior Member |
|
|
actually that task will be so easy if you can use a direct SELECT statement instead of a CURSOR
DECLARE
v_count NUMBER;
BEGIN
SELECT COUNT(*)
INTO v_count
FROM EMP
WHERE Emp_No = :HEADER.EMPNO;
IF v_count > 0 THEN
MESSAGE('The Number of Records Found - '||v_count);
ELSE
RAISE FORM_TRIGGER_FAILURE;
END IF;
END;
(OR)
DECLARE
v_empno NUMBER;
BEGIN
SELECT Emp_No
INTO v_empno
FROM EMP
WHERE Emp_No = :HEADER.EMPNO;
MESSAGE('This means it has got some Records');
EXCEPTION
WHEN NO_DATA_FOUND THEN
MESSAGE('No Data Found..!!');
RAISE FORM_TRIGGER_FAILURE;
WHEN OTHERS THEN
MESSAGE('Error - '||SQLCODE);
END;
Hope this helps..!!
|
|
|
|