On-Fetch Trigger
Description
When a query is first opened, fires immediately after the On-Select
trigger fires, when the first records are fetched into the block. While the
query remains open, fires again each time a set of rows must be fetched into
the block.
Definition Level form or block
Legal Commands
SELECT statements, PL/SQL, unrestricted Built-ins
Enter Query Mode no
Usage Notes
- When you write an On-Fetch trigger to replace default fetch processing,
the trigger must do the following:
- Retrieve the appropriate number of records from the non-ORACLE data
source, as indicated by the setting of the Records_To_Fetch
property.
- Create that number of queried records in the current block.
- Populate the records with the retrieved data.
- Create queried records from an On-Fetch trigger by calling the CREATE_QUERIED_RECORD
Built-in subprogram.
- While the query remains open, the On-Fetch trigger continues to fire as
more records are needed in the block. This behavior continues:
- until no queried records are created in a single execution of the trigger.
Failing to create any records signals an end-of-fetch to Oracle Forms,
indicating that there are no more records to be retrieved.
- until the query is closed, either by the operator or programmatically
through a call to ABORT_QUERY.
- until the trigger raises the Built-in exception FORM_TRIGGER_FAILURE.
- To perform the default Oracle Forms processing from this trigger, include
a call to the FETCH_RECORDS Built-in.
- Do not use an ABORT_QUERY Built-in
in an On-Fetch trigger. ABORT_QUERY is not valid in an On-Fetch trigger, and
produces inconsistent results.
On Failure
no effect
Fires In
Fetch Records
On-Fetch Trigger Examples
This example calls a client-side package function to retrieve the proper number
of rows from a package cursor.
DECLARE
j NUMBER := Get_Block_Property(blk_name, RECORDS_TO_FETCH);
emprow emp%ROWTYPE;
BEGIN
FOR ctr IN 1..j LOOP
/*
** Try to get the next row.
*/
EXIT WHEN NOT MyPackage.Get_Next_Row(emprow);
Create_Queried_Record;
:Emp.rowid := emprow.ROWID;
:Emp.empno := emprow.EMPNO;
:Emp.ename := emprow.ENAME;
:
:
END LOOP;
IF form_fatal OR form_failure THEN
raise form_trigger_failure;
END IF;
END
;
Related topic
CREATE_QUERIED_RECORD Built-in