In Oracle reports we use Formula column, Summary column and Place
Holder column in different scenarios, this post is to avoid confusion
and give clear picture as when and where we need to use these columns.
Formula columns can be written using PL/SQL syntax and we can use pl/sql functions for computation on the data. Formula column will accept data of Character, Number, or Date type.
Inside or outside data group?
If we want to calculate a value for every row place the formula column in the group of the data model , so that it called every time for every record and if we want to derive a value at report level place the formula column outside to the data group.
Formula columns are generally preceded by CF_ to distinguish from other columns. Column names or parameters with a prefix ‘:’ in formula column are considers as input to a formula column.
Examples:
The datatype of a summary column depends on the data type of the source of the summary. If you change the data type of the source column, the datatype of the summary also changes.
In report layout summary columns should be used out of repeating frames. Summary columns will have only one parameter as input.
Below are the standard functions provided by Oracle for a summary column
Inside or outside data group?
We can use this place holder columns inside the data group or outside the data group.
Place Holder column can be of Character, Date or Number datatype. Place Holder columns are generally preceded by CP_ to distinguish from other columns.
function CF_Cal_MaxPaymentFormula return Number is
begin
if :Payments=:CS_Max_Pay then
:CP_MAX_Payer:= :vendor_name;
end if;
return (1);
end;
--take CF_CalMaxPaymentFormul as group Level in group
--CP_MAX_Payer is a report level out side the group placeholder column with data type Character 80
--CS_Max_Pay is a report level Summary Column having maxiumn Payments using max function
Formula column
We use formula column to calculate some information dynamically using information based on the columns of the data model or from the concurrent program parameters. It is basically used to apply some custom logic on input data and return some value.Formula columns can be written using PL/SQL syntax and we can use pl/sql functions for computation on the data. Formula column will accept data of Character, Number, or Date type.
Inside or outside data group?
If we want to calculate a value for every row place the formula column in the group of the data model , so that it called every time for every record and if we want to derive a value at report level place the formula column outside to the data group.
Formula columns are generally preceded by CF_ to distinguish from other columns. Column names or parameters with a prefix ‘:’ in formula column are considers as input to a formula column.
Examples:
- Comparison of data in two different columns/variables and perform some action.
- Using some standard oracle pl/sql functions to find out some values
like, finding out the master org using oracle standard function as
shown below
oe_sys_parameters.VALUE('MASTER_ORGANIZATION_ID',mo_global.get_current_org_id())
- When you need to use any If-else block
- To execute some sql query to find out email-address of a party using party_id
Different Columns contained in Report Builder are:
1) Data Columns
2) Formula Columns
3) Summary Columns
4) Placeholder Columns
Data Columns:
Data Columns contain the data values for a report.
Data Columns are corresponding to the table columns included in the select list of a query.
Each column is placed in the group associated with the query.
Formula Columns:
Formula Columns performs user-defined computations.
Formula Columns executes a PL/SQL function and must return a value.
Formula Columns can be placed at the Report or Query level.
Formula Columns should not be used to set a parameter’s value.
Formula Columns should not be used to set a parameter’s value.
Formula Columns is denoted by CF_
| |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
|
Summary column
Summary columns are used for calculating summary information like sum, average etc,. on specific columns of a data group. This column uses a set of predefined oracle aggregate functions. Summary columns are generally preceded by CS_ to distinguish them from other columns.The datatype of a summary column depends on the data type of the source of the summary. If you change the data type of the source column, the datatype of the summary also changes.
In report layout summary columns should be used out of repeating frames. Summary columns will have only one parameter as input.
Below are the standard functions provided by Oracle for a summary column
Function | Purpose |
---|---|
Average | Calculates the average of the column’s values within the reset group. |
Count | Counts the number of records within the reset group. |
First | Prints the column’s first value fetched for the reset group. |
Last | Prints the column’s last value fetched for the reset group. |
Maximum | Calculates the column’s highest value within the reset group. |
Minimum | Calculates the column’s lowest value within the reset group. |
% of Total | Calculates the column’s percent of the total within the reset group. |
Std. Deviation | Calculates the column’s positive square root of the variance for the reset group. |
Sum | Calculates the total of the column’s values within the reset group. |
Variance | Sums the squares of each column value’s distance from the mean value of the reset group and divides the total by the number of values minus 1. |
All the above functions work only for number datatype column and return number datatype.
Place Holder column
Place holder column is an empty container at design time which is used to hold some value in run time, they are like local/global variables which can be used in the logic of a formula column or in report triggers. Value in the place holder column can be directly accessible in the report layout.Inside or outside data group?
We can use this place holder columns inside the data group or outside the data group.
Place Holder column can be of Character, Date or Number datatype. Place Holder columns are generally preceded by CP_ to distinguish from other columns.
Example of Usage of PlaceHolder Column
function CF_Cal_MaxPaymentFormula return Number is
begin
if :Payments=:CS_Max_Pay then
:CP_MAX_Payer:= :vendor_name;
end if;
return (1);
end;
--take CF_CalMaxPaymentFormul as group Level in group
--CP_MAX_Payer is a report level out side the group placeholder column with data type Character 80
--CS_Max_Pay is a report level Summary Column having maxiumn Payments using max function
FUNCTION dept_name IS RETURN VARCHAR2 ( 50 ) BEGIN DECLARE t_dname VARCHAR2( 50 ); t_loc VARCHAR2( 50 ); CURSOR c_dept IS SELECT dname, loc FROM dept WHERE deptno = :deptno; BEGIN OPEN c_dept; FETCH c_dept INTO t_dname, t_loc; IF c_dept%FOUND THEN CLOSE c_dept; :place_loc := t_loc; -- PLACE HOLDER COLUMN ELSE CLOSE c_dept; END IF; RETURN t_dname; END; END;
What is a Place Holder Column?
In any programming
language we do declare local or global variables to store the values
and use the values as per needed. In Oracle report tool we use place
holder column for the same purpose. Place Holder column can be of
Character, Date or Number datatype. We can use this place holder columns inside the data group or outside the data group. Usually we need the place holder column when we want to derive multiple values in a single program unit and return multiple values. We use a formula column to derive few values for a particular record in the data group and want to return multiple values. Since formula column is based on a function and can return only a single value we use multiple place holder columns to store multiple values so that we can display then on the report. |
Nice Explanation....
ReplyDeleteNice Explanation
ReplyDeletePlease solution
ReplyDeleteNice explanation
ReplyDeleteGreat, The type of article you describe is exactly what I was looking for .Turkish visa Australia specifically for Australian citizens. With this visa an Australian visa applicant can easily visit in Turkish .
ReplyDeleteTül perde modelleri
ReplyDeleteNumara Onay
turkcell mobil ödeme bozdurma
Https://nftnasilalinir.com
Ankara evden eve nakliyat
Trafik Sigortasi
dedektor
Web Site Kurma
aşk kitapları
smm panel
ReplyDeleteSmm panel
İŞ İLANLARI
instagram takipçi satın al
hirdavatciburada.com
Beyazesyateknikservisi.com.tr
SERVİS
Jeton Hilesi İndir
lisans satın al
ReplyDeleteyurtdışı kargo
nft nasıl alınır
minecraft premium
en son çıkan perde modelleri
özel ambulans
en son çıkan perde modelleri
uc satın al