Blog Structure
- Introduction
Oracle Reports provides Placeholder Columns to store values that are not directly retrieved from the SQL query. These values can be assigned dynamically using report triggers such as the Before Report Trigger.
- What is a Placeholder Column?
A Placeholder Column is a column in the Data Model that does not retrieve data from the database. Instead, its value is assigned programmatically in report triggers or PL/SQL.
Uses:
- Store calculated values
- Display dynamic text
- Pass values between report components
- Retrieve values from another table
- What is the Before Report Trigger?
The Before Report Trigger executes before the report starts fetching data.
Typical uses include:
- Initializing variables
- Populating placeholder columns
- Validating parameters
- Fetching values from other tables
- Steps to Create a Placeholder Column
- Open the RDF in Oracle Reports Builder.
- Navigate to the Data Model.
- Create a Placeholder Column.
- Assign the appropriate datatype.
- Name it (for example, CP_REFERENCE_DOC).
- Writing Logic in the Before Report Trigger
Example:
function Before Report return Boolean is
begin
NULL;
select PRODUCT_CODE into: CP_Product_code From apex.xxxx_odm_runcard_header orch where BATCH_NO=:p_batch_no
select DBMS_LOB.SUBSTR(NOTE, 4000, 1) AS NOTE,MAX(ROUTING_SEQUENCE) AS ROUTING_SEQUENCE,REFERENCE_DOCUMENT_ID, REVISION_NO_AND_DATE
into :CP_Note,:CP_QC_Final_operation,:CP_REFERENCE_DOCUMENT_ID,:CP_REVISION_NO_AND_DATE FROM APEX.XXX_ODM_RUN_CARD
WHERE DBMS_LOB.SUBSTR(ATTACHMENT, 4000, 1) <> ‘N/A’
AND PRODUCT_NUMBER = :CP_PRODUCT_CODE
GROUP BY
DBMS_LOB.SUBSTR(NOTE, 4000, 1),
REFERENCE_DOCUMENT_ID,
REVISION_NO_AND_DATE;
return (TRUE);
exception
when others then null;
return (TRUE); end;
- Validation
After implementing the Placeholder Column logic, perform functional testing to ensure the report retrieves and displays the expected information. Validate the output against the source data and confirm that all business requirements are met.
- Advantages
- Reduces SQL complexity
- Keeps business logic separate
- Improves report flexibility
- Easy to maintain