This section shows the text of the master-detail procedures that Oracle Forms creates automatically when you define a relation. These procedures are called from the master-detail triggers or from other procedures.
This procedure is called by the On-Clear-Details trigger. It navigates to the detail block and clears the detail records.
PROCEDURE Clear_All_Master_Details IS
mastblk CHAR(30); /* Initial Master Block Causing Coord */
coordop CHAR(30); /* Operation Causing the Coord */
trigblk CHAR(30); /* Cur Block On-Clear-Details Fires On*/
startitm CHAR(61); /* Item in which cursor started */
frmstat CHAR(15); /* Form Status */
curblk CHAR(30); /* Current Block */
currel CHAR(30); /* Current Relation */
curdtl CHAR(30); /* Current Detail Block */
FUNCTION First_Changed_Block_Below( Master CHAR ) RETURN CHAR
IS
curblk CHAR(30); /* Current Block */
currel CHAR(30); /* Current Relation */
retblk CHAR(30); /* Return Block */
BEGIN
/*
** Init Local Vars
*/
curblk := Master;
currel :=Get_Block_Property(curblk,FIRST_MASTER_RELATION);
/*
** While there exists another relation for this block
*/
WHILE currel IS NOT NULL LOOP
/*
** Get the name of the detail block
*/
curblk := Get_Relation_Property(currel,DETAIL_NAME);
/*
** If this block has changes, return its name
*/
IF Get_Block_Property(curblk,STATUS) IN
('CHANGED','INSERT') THEN
RETURN curblk;
/*
** Otherwise, recursively look for changed blocks below
*/
ELSE
retblk := First_Changed_Block_Below(curblk);
/*
** If some block below is changed, return its name
*/
IF retblk IS NOT NULL THEN
RETURN retblk;
/*
** Otherwise, Consider the next relation
*/
ELSE
currel := Get_Relation_Property (currel,
NEXT_MASTER_RELATION);
END IF;
END IF;
END LOOP;
/*
** If we get here, no changed blocks were found
*/
RETURN NULL;
END First_Changed_Block_Below;
BEGIN
/*
** Init Local Vars
*/
mastblk := :System.Master_Block;
coordop := :System.Coordination_Operation;
trigblk := :System.Trigger_Block;
startitm := :System.Trigger_Item;
frmstat := :System.Form_Status;
/*
** If the coord op is anything but CLEAR_RECORD, then
** continue checking.
*/
IF coordop <> 'CLEAR_RECORD' THEN
/*
** If we're processing the driving master block...
*/
IF mastblk = trigblk THEN
/*
** If something in the form is changed, find the
** first changed block below the master
*/
IF frmstat = 'CHANGED' THEN
curblk := First_Changed_Block_Below(mastblk);
/*
** If we find a changed block below, go there
** and Ask to commit the changes.
*/
IF curblk IS NOT NULL THEN
Go_Block(curblk);
Check_Package_Failure;
Clear_Block(ASK_COMMIT);
/*
** If user cancels commit dialog, raise error
*/
IF NOT( :System.Form_Status = 'QUERY' /* Yes */ OR
:System.Block_Status = 'NEW' /* No */ ) THEN
RAISE Form_Trigger_Failure;
END IF;
END IF;
END IF;
END IF;
END IF;
/*
** Clear all the detail blocks for this master without
** any further asking to commit.
*/
currel := Get_Block_Property(trigblk,FIRST_MASTER_RELATION);
WHILE currel IS NOT NULL LOOP
curdtl := Get_Relation_Property(currel,DETAIL_NAME);
IF ( Get_Block_Property(curdtl, STATUS) <> 'NEW' ) THEN
Go_Block(curdtl);
Check_Package_Failure;
Clear_Block(NO_VALIDATE);
IF ( :System.Block_Status <> 'NEW' ) THEN
RAISE Form_Trigger_Failure;
END IF;
END IF;
currel := Get_Relation_Property(currel,NEXT_MASTER_RELATION);
END LOOP;
/*
** Put cursor back where it started
*/
IF ( :System.Cursor_Item <> startitm ) THEN
Go_Item(startitm);
END IF;
EXCEPTION
WHEN Form_Trigger_Failure THEN
IF :System.Cursor_Item <> startitm THEN
Go_Item(startitm);
END IF;
RAISE;
END Clear_All_Master_Details;
This procedure is called from the On-Populate-Details trigger. It navigates to the detail block and then executes a query to fetch the appropriate detail records.
PROCEDURE Query_Master_Details(rel_id Relation, detail CHAR) IS
oldmsg CHAR(2); /* Old Message Level Setting */
reldef CHAR(5); /* Relation Deferred Setting */
BEGIN
/*
** Initialize Local Variable(s)
*/
reldef := Get_Relation_Property(rel_id,
DEFERRED_COORDINATION);
oldmsg := :System.Message_Level;
/*
** If NOT Deferred, Goto detail & execute the query.
*/
IF reldef = 'FALSE' THEN
Go_Block(detail);
Check_Package_Failure;
:System.Message_Level := '5';
Execute_Query;
:System.Message_Level := oldmsg;
/*
** If Deferred, Mark the detail block as un-coordinated
*/
ELSE
Set_Block_Property(detail, coordination_status,
NON_COORDINATED);
END IF;
EXCEPTION
WHEN Form_Trigger_Failure THEN
:System.Message_Level := oldmsg;
RAISE;
END Query_Master_Details;
This procedure is called by the CLEAR_ALL_MASTER_DETAILS and QUERY_MASTER_DETAILS procedures. It checks to see if the previous statement executed successfully by looking at the status of the Built-in Oracle Forms error variable FORM_SUCCESS.
PROCEDURE Check_Package_Failure IS
BEGIN
IF (NOT Form_Success) THEN
RAISE Form_Trigger_Failure;
END IF;
END;