Home » Developer & Programmer » Forms » Exception NO_DATA_FOUND
Exception NO_DATA_FOUND [message #625374] Tue, 07 October 2014 01:10 Go to next message
Mayur Shinde
Messages: 60
Registered: August 2014
Location: Pune, Maharashtra
Member
I am using below code to find string. If entered string not matched then cursor is pointing at last record. But i have to display message "No data found".
DECLARE	
BEGIN
	IF :BLOCK_TOOL.S_GRADE_DESC IS NULL THEN
		 ERR_MESSAGE('Please enter Grade Code OR Grade Description...');		 
		 SET_ITEM_PROPERTY('BLOCK_TOOL.S_GRADE_DESC',ENABLED,PROPERTY_TRUE);
		 GO_ITEM('BLOCK_TOOL.S_GRADE_DESC');
	ELSE 
	   BEGIN
		     GO_BLOCK('TRANSACTIONS_MST');
		     FIRST_RECORD;		     
		     LOOP
		     	 IF   :TRANSACTIONS_MST.GRADE_DESC like '%'||:BLOCK_TOOL.S_GRADE_DESC||'%' 
		     	 	 OR :TRANSACTIONS_MST.GRADE_CD LIKE '%'||:BLOCK_TOOL.S_GRADE_DESC||'%' THEN
	   	            EXIT;		     	 
		     	 END IF;
		     	 NEXT_RECORD;		     	 
		     	 EXIT WHEN :SYSTEM.LAST_RECORD='TRUE'; 
	       END LOOP;	       
	   END;	
	   
  END IF;
END;

Re: Exception NO_DATA_FOUND [message #625375 is a reply to message #625374] Tue, 07 October 2014 01:29 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Declare a counter. Add 1 to it if you find a match. At the end of the trigger code, check whether counter's value is larger than 1. If not, display a message.
Re: Exception NO_DATA_FOUND [message #625376 is a reply to message #625375] Tue, 07 October 2014 01:34 Go to previous messageGo to next message
Mayur Shinde
Messages: 60
Registered: August 2014
Location: Pune, Maharashtra
Member
Could you please explain it in code...!
Re: Exception NO_DATA_FOUND [message #625378 is a reply to message #625376] Tue, 07 October 2014 02:01 Go to previous messageGo to next message
Mayur Shinde
Messages: 60
Registered: August 2014
Location: Pune, Maharashtra
Member
THANK YOU..
I done it.
below is the code :
DECLARE	
	counter number :=0;
	ALERT_BUTTON5 number;
BEGIN	
	IF :BLOCK_TOOL.S_GRADE_DESC IS NULL THEN
		 ERR_MESSAGE('Please enter Grade Code OR Grade Description...');		 
		 SET_ITEM_PROPERTY('BLOCK_TOOL.S_GRADE_DESC',ENABLED,PROPERTY_TRUE);
		 GO_ITEM('BLOCK_TOOL.S_GRADE_DESC');
	ELSE 
	   BEGIN
		     GO_BLOCK('TRANSACTIONS_MST');		     
		     FIRST_RECORD;		     
		     LOOP
		     	 IF   :TRANSACTIONS_MST.GRADE_DESC like '%'||:BLOCK_TOOL.S_GRADE_DESC||'%' 
		     	 	 OR :TRANSACTIONS_MST.GRADE_CD LIKE '%'||:BLOCK_TOOL.S_GRADE_DESC||'%' THEN		     	 	      
		     	 	      counter := counter + 1;		     	 	      
	   	            EXIT;		     	 
		     	 END IF;
		     	 NEXT_RECORD;		     	 
		     	 EXIT WHEN :SYSTEM.LAST_RECORD='TRUE'; 
		     	 
		     END LOOP;
		    
		     IF counter < 1 THEN
		     	  ALERT_BUTTON5 := SHOW_ALERT('NO_DATA_FOUND');		     	 
		     END IF;	     		
	   
	   END;	   
	   
  END IF;
END;

Re: Exception NO_DATA_FOUND [message #625547 is a reply to message #625378] Thu, 09 October 2014 23:23 Go to previous messageGo to next message
Mayur Shinde
Messages: 60
Registered: August 2014
Location: Pune, Maharashtra
Member
In the above code the case is given below:
On the form I have three Items i.e. ABC, ADC, AZS

In the search condition when I insert 'A' for search then from above code
it is able to find first appearance of character i.e 'ABC'.

But Now, how to find next Element i.e 'ADC' and 'AZS'.

Please help me...
Re: Exception NO_DATA_FOUND [message #625548 is a reply to message #625547] Fri, 10 October 2014 00:04 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Try with INSTR function.
Re: Exception NO_DATA_FOUND [message #625549 is a reply to message #625548] Fri, 10 October 2014 00:19 Go to previous messageGo to next message
Mayur Shinde
Messages: 60
Registered: August 2014
Location: Pune, Maharashtra
Member
how can i do above functionality with INSTR..?
Re: Exception NO_DATA_FOUND [message #625552 is a reply to message #625549] Fri, 10 October 2014 00:56 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
As you are looking for 'A', you'd
if instr(:item, 'A') > 0 then 
   message('A exists in that item');
end if;


Or, if you were looking for 'Littlefoot', you'd
if instr(:item, 'Littlefoot') > 0 then ...
etc.
Re: Exception NO_DATA_FOUND [message #625553 is a reply to message #625552] Fri, 10 October 2014 01:16 Go to previous messageGo to next message
Mayur Shinde
Messages: 60
Registered: August 2014
Location: Pune, Maharashtra
Member
Using INSTR function I am getting same functionality same as before I used
using like operator.

My problem is:
On the form am having record's as like below:
--------
ABC
BBC
CBC
ADB
XYZ
AZS
-----------

1. When I enter character "A" for search and clicked on SEARCH button then at first, cursor pointing at record "ABC".

2. Now, If I clicked again on Search button then cursor should be on 4th
record i.e "ADB".

Above functionality will be done up to last record.

---------------------------------------------------------
I done first point please help me for 2 point.
Re: Exception NO_DATA_FOUND [message #625554 is a reply to message #625553] Fri, 10 October 2014 01:22 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
WHEN-BUTTON-PRESSED trigger should know where you are (i.e. row #1) - to do that, create a parameter (or a global variable) which will hold that information.

When you push the button for the second time, code would
go_record(:parameter.previous_row);
next_record;
loop
  Check whether item in current row contains information you are looking for.
  If it does, stop (i.e. exit the loop) and save the position.
  If not, go to the next record.
end loop

[Updated on: Fri, 10 October 2014 01:22]

Report message to a moderator

Re: Exception NO_DATA_FOUND [message #625555 is a reply to message #625554] Fri, 10 October 2014 02:05 Go to previous messageGo to next message
Mayur Shinde
Messages: 60
Registered: August 2014
Location: Pune, Maharashtra
Member
Thank you..
Problem solved...

[Updated on: Fri, 10 October 2014 02:25]

Report message to a moderator

Re: Exception NO_DATA_FOUND [message #625563 is a reply to message #625555] Fri, 10 October 2014 04:57 Go to previous messageGo to next message
Mayur Shinde
Messages: 60
Registered: August 2014
Location: Pune, Maharashtra
Member
I wrote below mentioned code :
DECLARE	
	counter number :=0;
	ALERT_BUTTON5 number;	
BEGIN	
	
	GO_BLOCK('TRANSACTIONS_MST');	
		last_record;
		:GLOBAL.las_rec := :system.cursor_record;
		err_message(:GLOBAL.las_rec);
		first_record;
		:GLOBAL.fas_rec := :system.cursor_record;
		err_message(:GLOBAL.fas_rec);
	
	IF :BLOCK_TOOL.S_GRADE_DESC IS NULL THEN
		 ERR_MESSAGE('Please enter Grade Code OR Grade Description...');		 
		 SET_ITEM_PROPERTY('BLOCK_TOOL.S_GRADE_DESC',ENABLED,PROPERTY_TRUE);
		 GO_ITEM('BLOCK_TOOL.S_GRADE_DESC');
	ELSE 
				
	   BEGIN 
		     	if :GLOBAL.curr_no =0 then 
		          GO_BLOCK('TRANSACTIONS_MST');		     
		          FIRST_RECORD;		     
		          LOOP
		     	       IF   :TRANSACTIONS_MST.GRADE_DESC LIKE '%'||:BLOCK_TOOL.S_GRADE_DESC||'%' 
		     	 	       OR :TRANSACTIONS_MST.GRADE_CD LIKE '%'||:BLOCK_TOOL.S_GRADE_DESC||'%' THEN		     	 	      
		     	 	          counter := counter + 1;	
		     	 	          :GLOBAL.curr_no := :system.cursor_record;	     	 	      
	   	                EXIT;		     	 
		     	       END IF;
		     	 
		     	    	 
		     	      	      	     	 
		     	    EXIT WHEN :SYSTEM.LAST_RECORD='TRUE'; 
		     	    NEXT_RECORD;
		     	 
		    	    END LOOP;
		    	
		    	elsif :GLOBAL.curr_no > 0 then
		            go_block('TRANSACTIONS_MST');
		    	      go_record(:GLOBAL.curr_no);
		    	      
		    	      IF :SYSTEM.CURSOR_RECORD <> :GLOBAL.las_rec THEN
		    	      
		    	      next_record;		    	      
		    	      loop
		    		        if   :transactions_mst.grade_desc like '%'||:block_tool.s_grade_desc||'%'
		    		          or :transactions_mst.grade_cd like '%'||:block_tool.s_grade_desc||'%' then
		    		          counter := counter + 1;
		    		          :GLOBAL.curr_no := :system.cursor_record;	
		    		          exit;
		    	 	        end if;
		    		    
		    		    exit when :system.last_record='true';
		    		    next_record;
		    	      end loop;
		    	      ELSE
		    	      	ERR_MESSAGE('LAST RECORD');
		    	      END IF;
		    	
	        end if;
	 		    
		     IF counter < 1 THEN
		     	  ALERT_BUTTON5 := SHOW_ALERT('NO_DATA_FOUND');
		     	  first_record;
		     	  go_item('block_tool.s_grade_desc');
		     END IF;	     		
	   
	   END;	  
  END IF;
END;



Now the new thing is when no any match found then cursor is in infinite loop instead of exit at last record.
Please help me..
Re: Exception NO_DATA_FOUND [message #625565 is a reply to message #625563] Fri, 10 October 2014 05:13 Go to previous message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
		     	    EXIT WHEN :SYSTEM.LAST_RECORD='TRUE';
.....
.....
		    		    exit when :system.last_record='true';


case matters when checking data.
Previous Topic: Canvas
Next Topic: Forms 11 and java
Goto Forum:
  


Current Time: Wed Apr 17 23:40:46 CDT 2024