Home » Developer & Programmer » Forms » Help:Exception when_no_data_found
Help:Exception when_no_data_found [message #242435] Sat, 02 June 2007 01:39 Go to next message
lune
Messages: 27
Registered: August 2006
Location: UAE
Junior Member
Hello

The code is for searching records. It is working and showing the result correctly and when there is no result nothing appear which is right but I want to show an alert saying "No Data Found" when there is no result. I add the exception part but it didn't work.

here is the code:
DECLARE ALERT_CHOICE NUMBER;    
M_DATE varchar(50):=:FIND_MEETING_DATE;
M_ROOM varchar(50):=:ROOM_ID;

CURSOR GETMEETING IS
SELECT MEETING_ID,ROOM_ID,MEETING_DATE,MEETING_START_TIME,MEETING_FINISH_TIME
FROM MY_MEETINGS
WHERE MEETING_DATE like '%'||M_DATE||'%' AND ROOM_ID like '%'||M_ROOM||'%';


BEGIN
        GO_BLOCK('MY_MEETINGS');
        CLEAR_BLOCK;
        IF (:SEARCH.FIND_MEETING_DATE IS NULL OR :SEARCH.ROOM_ID IS NULL) THEN
                SET_ALERT_PROPERTY('ERROR_ALERT',ALERT_MESSAGE_TEXT,'fields can not be empty!!!');
                SET_ALERT_PROPERTY('ERROR_ALERT',TITLE,'ERROR');
                ALERT_CHOICE := SHOW_ALERT('ERROR_ALERT');
                GO_ITEM('FIND_MEETING_DATE');
        ELSE        
        
            OPEN GETMEETING;
            LOOP
            FETCH GETMEETING INTO :MEETING_ID,:ROOM_ID,:MEETING_DATE,:MEETING_START_TIME,:MEETING_FINISH_TIME;
            GO_BLOCK('MY_MEETINGS');
                NEXT_RECORD;    
                
            EXIT WHEN GETMEETING%NOTFOUND;
            
            END LOOP;
            
            END IF;
        
            CLOSE GETMEETING;

                :SEARCH.FIND_MEETING_DATE := NULL;
                    :SEARCH.ROOM_ID := NULL;
                GO_ITEM('FIND_MEETING_DATE');



         --THIS PART IS WOT WORKING       
        EXCEPTION
            WHEN NO_DATA_FOUND THEN
            SET_ALERT_PROPERTY('ERROR_ALERT',ALERT_MESSAGE_TEXT,No result found !!!');
                SET_ALERT_PROPERTY('ERROR_ALERT',TITLE,'ERROR');
                ALERT_CHOICE := SHOW_ALERT('ERROR_ALERT');
                :SEARCH.FIND_MEETING_DATE := NULL;
                    :SEARCH.ROOM_ID := NULL;
                GO_ITEM('FIND_MEETING_DATE');
                
            
END;



Waiting your suggestion
lune
Re: Help:Exception when_no_data_found [message #242454 is a reply to message #242435] Sat, 02 June 2007 04:29 Go to previous messageGo to next message
kamran.it
Messages: 265
Registered: September 2005
Location: Karachi
Senior Member
Please try this

	 EXCEPTION
  WHEN NO_DATA_FOUND THEN


         message(' No Record Found. Please Check!!!!');
         message(' ');
         raise form_trigger_failure;


Re: Help:Exception when_no_data_found [message #242471 is a reply to message #242454] Sat, 02 June 2007 08:22 Go to previous messageGo to next message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
This exception is never reached ... even if there's no record in a cursor, the EXIT WHEN cursor%NOTFOUND exits the loop and that's it.

You'll have to check how many records cursor returned and act accordingly to it. Modify the code to look like this:
fetch getmeeting ...;

if getmeeting%rowcount = 0 then
   put_the_alert_here;
end if;

exit when getmeeting%notfound;
Re: Help:Exception when_no_data_found [message #242516 is a reply to message #242435] Sun, 03 June 2007 06:53 Go to previous messageGo to next message
lune
Messages: 27
Registered: August 2006
Location: UAE
Junior Member
Thanks alot for your reply

littlefoot I added your code and it is working

Another problem I just see is that all the result of start_time and Finish_time is appearing at 12:00 AM

http://www.swahl.com/up/m85/swahlcom_1359.jpg

In all other forms it is the time is appearing correctlty but I dont know what is the problem here

Any Ideas

Thanks again for your help
lune

Re: Help:Exception when_no_data_found [message #242554 is a reply to message #242516] Mon, 04 June 2007 01:19 Go to previous message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
What is the item data type? Is it a DATE? If so, try to change it to DATETIME.
Previous Topic: 10g forms run in browser
Next Topic: Please correct the code
Goto Forum:
  


Current Time: Fri Dec 02 20:26:58 CST 2016

Total time taken to generate the page: 0.10910 seconds