Cursor exception with True and False messages [message #678569] |
Mon, 16 December 2019 04:59  |
kilimanjaro
Messages: 151 Registered: May 2009 Location: Tanzania
|
Senior Member |
|
|
Hellow Friends,Im not that much of an expert ....
Im trying to display message when cursor find data and when It doesn't find data..
When It finds data a pop up message should display....do you want to proceed?
here is my code...compiled successful but doesn't yield results.Thank you.
----------------
DECLARE
reg std_registration.reg_number%TYPE;
first_name std_registration.first_name%TYPE;
shule std_registration.school_level%TYPE;
reg2 students_1.reg_number%TYPE;
check_namba number;
n number;
CURSOR cur_stclerk IS
select a.reg_number,a.first_name,a.school_level from std_registration a,std_interview3 b
where a.reg_number=:STD_REGISTRATION.reg_number
and :STD_REGISTRATION.reg_number not in (select reg_number from students_1 )
and a.reg_number=b.reg_number
and b.action like 'Accepted';
BEGIN
-- DBMS_OUTPUT.put_line ('--- Starting processing of Student ---');
select reg_number
into check_namba
from students_1
where reg_number =:STD_REGISTRATION.reg_number;
if check_namba=:STD_REGISTRATION.reg_number then
n := show_alert('ALERT210');
else
OPEN cur_stclerk;
LOOP
FETCH cur_stclerk INTO reg,first_name,shule;
EXIT WHEN cur_stclerk%NOTFOUND;
INSERT INTO students_1
(reg_number,full_name, school_level)
VALUES (reg,first_name,shule);
n := show_alert('ALERT213');
IF cur_stclerk%NOTFOUND
THEN
DBMS_OUTPUT.put_line ('No record matched with your input empno !' );
EXIT;
--
END if;
end LOOP;
COMMIT;
-- n := show_alert('ALERT210');
/* THEN
Message('User_Warning alert does not exist');
RAISE Form_Trigger_Failure;
end if;*/
--Message('Student Posted Successfull');*/
--else Message('This has been posted Previousely.Query the the Students form to Veryfy');
END if;
end;
------------------------
[Updated on: Mon, 16 December 2019 05:07] Report message to a moderator
|
|
|
|
Re: Cursor exception with True and False messages [message #678577 is a reply to message #678570] |
Mon, 16 December 2019 10:45  |
cookiemonster
Messages: 13904 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
As far as I'm aware forms doesn't display dbms_output, so using that is a waste of time.
If you want to display a message to users you should use the message builtin (as you are doing in the commented code).
You've got code like this
LOOP
IF CURSOR%NOTFOUND THEN
EXIT LOOP
END IF
IF CURSOR%NOTFOUND THEN
dbms_output.....
END IF
END LOOP
That 2nd IF can never be true because of the first IF.
Exit immediately exits the loop. Any code after exit in a loop is not run.
|
|
|