From your description I assume that at one time the request is only handle 1 record for update. If this is the case you can define a Function that return the message instanously. like below (I also assume all columns are varchar2, you just have to replace it accordingly).
Function sfc_upd_emp (p_empid varchar2, street_address varchar2, city varchar2, state varchar2, zip varchar2) return varchar2 is
vchEmpID varchar2(10);
begin
select empID into vchEmpID
from emp where empid=p_empid;
update emp
set .......
where empId = vchEmpID;
commit;
return 'Update Success !';
exception when no_data_found then
return 'Invalid Emp ID !';
end;
I used it personally for some of my projects...
I wish it helps.
Main Topics
Browse All Topics





by: jwahlPosted on 2007-08-20 at 22:25:58ID: 19735693
there are many ways, but your solution surly is a good one.
create a procedure with IN parameter p_empid and two OUT parameters: p_errorcode NUMBER, p_errortext VARCHAR2 for example.
if p_errorcode return 0 --> OK
otherwise: --> ERROR. use p_errorcode to describe the error.
the procedure could be very simple:
DECLARE
CURSOR emp_c IS
SELECT * FROM emp
WHERE empid = p_empid FOR UPDATE;
BEGIN
FOR emp_rt IN emp_c
LOOP
UPDATE emp
SET ....
WHERE CURRENT OF emp_c;
--
p_errorcode := 0;
p_errortext := 'Update successfull';
--
END LOOP;
--
IF p_errorcode IS NULL THEN
p_errorcode := 1;
p_errortext := 'Error: No Record found for p_empid=' || p_empid;
END IF;
--
EXCEPTION
....
END;
here will never raise a NO_DATA_FOUND exception, because the cursor closes immediatly when no records match.