Home » Developer & Programmer » Forms » Navigate to Particular Record
Navigate to Particular Record [message #625023] Tue, 30 September 2014 07:04 Go to next message
Mayur Shinde
Messages: 60
Registered: August 2014
Location: Pune, Maharashtra
Member
Hi,
I have table name as "TRANS_MASTER" as given below:
-------------------------------
code|description|value1|value2 
-------------------------------
1   | A         | 10   | 100
2   | B         | 20   | 200
3   | C         | 30   | 300
4   | D         | 40   | 400
5   | E         | 50   | 500
------------------------------------

I am displaying the above record fine.
Now, if I give input = 1 then cursor should point to that particular record.

i.e. as per entered code cursor should be on that record...

Please help me...

[EDITED by LF: removed superfluous empty lines; applied [code] tags]

[Updated on: Tue, 30 September 2014 15:05] by Moderator

Report message to a moderator

Re: Navigate to Particular Record [message #625024 is a reply to message #625023] Tue, 30 September 2014 07:10 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Go to the first record.
Start a loop, check if the value in the current record is the one you want.
If not go to the next record.
Exit loop when you reach the right record or run out of records.
Re: Navigate to Particular Record [message #625054 is a reply to message #625024] Tue, 30 September 2014 13:34 Go to previous messageGo to next message
CraigB
Messages: 386
Registered: August 2014
Location: Utah, USA
Senior Member
One option would be to Loop through the records in a block to find the selected record. This is actually the most common method used. However, if you have a lot (100+) records displayed then looping through these records could take a while. When you have a lot of records displayed, I like to use a Record Group (RG) to keep track of all of the records displayed which allows you to search the RG for a particular value. Seaching through the RG is much faster than looping through your block and the RG will tell which Forms Record has your value so you can use the Go_Record() built-in to go directly to the desired record. To see a demo of how to use a RG, take a look at this link:
https://sites.google.com/site/craigsoraclestuff/oracle-forms---how-to-s/forms-how-to-select-multiple-records-in-a-block

Hope this helps,
Craig...
Re: Navigate to Particular Record [message #625060 is a reply to message #625024] Tue, 30 September 2014 23:45 Go to previous messageGo to next message
Mayur Shinde
Messages: 60
Registered: August 2014
Location: Pune, Maharashtra
Member
Hi,
I wrote below code :
DECLARE	
BEGIN
	IF :BLOCK_TOOL.SEARCH_GRADE_CODE IS NULL THEN
		 ERR_MESSAGE('Please enter Grade Code / Grade Description...');
	ELSE
	   GO_BLOCK('TRANSACTIONS_MST');
	   FIRST_RECORD;
	   LOOP
	   	  IF :TRANSACTIONS_MST.GRADE_CODE = :BLOCK_TOOL.SEARCH_GRADE_CODE THEN
	   	     SYSTEM.CURSOR_RECORD;
	      ELSE
	   	     NEXT_RECORD;
	      END IF;
	      EXIT WHEN :TRANSACTIONS_MST.GRADE_CODE = :BLOCK_TOOL.SEARCH_GRADE_CODE OR SYSTEM.LAST_RECORD = TRUE;
	END IF;
END;



The above code is not working and how to highlight that record.

Re: Navigate to Particular Record [message #625062 is a reply to message #625060] Wed, 01 October 2014 01:16 Go to previous messageGo to next message
Mayur Shinde
Messages: 60
Registered: August 2014
Location: Pune, Maharashtra
Member
Thank you.
Problem is resolved.
I write below code:
DECLARE	
BEGIN
	IF :BLOCK_TOOL.S_GRADE_CD IS NULL AND :BLOCK_TOOL.S_GRADE_DESC IS NULL THEN
		 ERR_MESSAGE('Please enter Grade Code OR Grade Description...');
		 GO_ITEM('BLOCK_TOOL.S_GRADE_CD');
	ELSE
	   BEGIN
		     GO_BLOCK('TRANSACTIONS_MST');
		     FIRST_RECORD;
		     LOOP
		     	 IF :TRANSACTIONS_MST.GRADE_CD = :BLOCK_TOOL.S_GRADE_CD OR :TRANSACTIONS_MST.GRADE_DESC = :BLOCK_TOOL.S_GRADE_DESC THEN
	   	        GO_ITEM(:SYSTEM.CURSOR_RECORD);
	         ELSE
	   	        NEXT_RECORD;
	         END IF;
	       EXIT WHEN :TRANSACTIONS_MST.GRADE_CD = :BLOCK_TOOL.S_GRADE_CD OR :TRANSACTIONS_MST.GRADE_DESC = :BLOCK_TOOL.S_GRADE_DESC OR :SYSTEM.LAST_RECORD='TRUE'; 
		     END LOOP;
		 EXCEPTION
		     WHEN NO_DATA_FOUND THEN
		     	ERR_MESSAGE('No Data found for above Grade Code OR Grade Description...!');
		 END;		     	
  END IF;
END;

Some one can suggest me for "On click of above 'CODE' column or 'Description' column, How to display records as either ascending or descending.."

[Updated on: Wed, 01 October 2014 01:17]

Report message to a moderator

Re: Navigate to Particular Record [message #625077 is a reply to message #625062] Wed, 01 October 2014 03:54 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
To get the data in a different order you would need to change the blocks order by property using set_block_property and then requery the data with execute_query.
There's nothing in the above code that will raise no_data_found by the way so that exception handler is pointless.
Re: Navigate to Particular Record [message #625129 is a reply to message #625077] Wed, 01 October 2014 10:48 Go to previous message
CraigB
Messages: 386
Registered: August 2014
Location: Utah, USA
Senior Member
Quote:
...and how to highlight that record.

I recommend using the Current Record Visual Attribute property of the block.

Craig...
Previous Topic: Highlight Multiple Rows In Oracle Form
Next Topic: How to change Push button color on Mouse over in forms 10g
Goto Forum:
  


Current Time: Fri Apr 19 17:00:55 CDT 2024