Home » Developer & Programmer » Forms » How to jump to the parent record in a hierachical table in forms
How to jump to the parent record in a hierachical table in forms [message #232153] Thu, 19 April 2007 11:39
real19
Messages: 1
Registered: April 2007
Junior Member
Hello

I have a hierarchical table that displays data in an oracle forms environment. All records have requirement ID and parent IDs and the Requirement ID reference parent ID.
Here is a structure of the table.

RQMT_ID
RQMT_LEVEL----- has levels like 10, 20, 30, 40, 50
CODE
PARENT_ID --- references RQMT ID
TITLE
QTY
SECTION
UI
UNIT_PRICE
TOTAL_PRICE

The way I have designed the form is that , when you double click a record , it takes you to its child records by searching for records that have the same parent ID.

I have a block level triggers that fires when you click on an item i.e.,
WHEN-MOUSE-DOUBLECLICK>>>>>>


DECLARE
v_max_level NUMBER;
BEGIN
:GLOBAL.g_rqmt_id := :REQUIREMENTS_SET.RQMT_ID;
:GLOBAL.g_rqmt_level := :REQUIREMENTS_SET.RQMT_LEVEL;
:GLOBAL.g_record_number := :SYSTEM.TRIGGER_RECORD; --gets the record number of the current record
SET_BLOCK_PROPERTY('REQUIREMENTS_SET', DEFAULT_WHERE, 'parent_id = :GLOBAL.g_rqmt_id');

Select max(rqmt_level)
into v_max_level
from requirements_set;

IF
:GLOBAL.g_rqmt_level = v_max_level
THEN
Message('You are at the bottom level');
ELSE
EXECUTE_QUERY;
END IF;
END;




Now the challenge at hand is that I have a "BACK" button which is supposed to take me back to the previous record where the records came from . The problem is that I am only able to go back one level using a global variable that stores the value of :SYSTEM.TRIGGER_RECORD and use the FIND_RECORD built-in to fetch that. But this only saves the value of the last level. Like in other words I cannot make it remeber the parent of the parent and go back to it without hard coding anything. here is what it does so far...

DECLARE
v_rqmt_level NUMBER;
v_parent_level NUMBER;
v_parent_id NUMBER;

BEGIN
v_parent_id := :REQUIREMENTS_SET.PARENT_ID;

SELECT rqmt_level
INTO v_parent_level
FROM requirements_set
WHERE rqmt_id= v_parent_id;

:GLOBAL.g_parent_level := v_parent_level;

SET_BLOCK_PROPERTY('REQUIREMENTS_SET', DEFAULT_WHERE, 'rqmt_level = :GLOBAL.g_parent_level');
GO_BLOCK('REQUIREMENTS_SET');
EXECUTE_QUERY;
GO_RECORD(:GLOBAL.g_record_number);
EXCEPTION
WHEN OTHERS THEN
Message('You are at the top most level');
END;


Is there a way for me to find a record based on the parent and have it jump to that record and also display other records in that table in that level but just have the cursor move to that one record? I would appreciate any help i can get on this.

Thanks,
Suleman
Previous Topic: Input problem
Next Topic: unable to retrieve data from cursor
Goto Forum:
  


Current Time: Thu Sep 26 22:47:20 CDT 2024