Oracle Apex: Aggregate show as top row - oracle

Currently I use interactive report of Oracle Apex
Column1 Column2
A1 1 2
A2 2 3
A3 3 4
A4 4 5
----------------------
10 14
After showing data, I do some calculation such as sum Column1, Column2 using aggregate function SUM of interactive report
But the result show as the last row of report so I have to scroll to see the result.
How can I show the result as the first row of report?
Column1 Column2
10 14
----------------------
A1 1 2
A2 2 3
A3 3 4
A4 4 5

This can be done using JavaScript/jQuery (of course this is only one of many ways this can be done, but it works).
The SQL statement that is used to create the report along with all the filter and search information is stored in
WWV_FLOW_WORKSHEET tables
Create a database package to generate that SQL and sum the columns that you want from that and return as XML.
Call that database package from a jQuery AJAX call then parse the XML and using jQuery add a row to the top (and bottom if you like) of the worksheet table and place the results there.
The JavaScript/jQuery function should be called from an after refresh dynamic action for the worksheet in question.
function htmldbIRTotals(worksheet,columnList) {
sessionId = $("#pInstance").val();
worksheetId = $(worksheet.triggeringElement).find(".a-IRR-table:last").attr("id");
baseReportId=parseInt("0"+$("#"+worksheetId+"_rpt_saved_reports").val());
u="'||pkg||'.getTotals?p_worksheet_id="+worksheetId+"&p_base_Report_Id="+baseReportId+"&p_session_id="+sessionId+"&p_columns="+columnList;
$.post(u,function(data) {
var xml = $.parseXML(data);
});
With sessionId, worksheetId, and baseReportId you can retrieve all the info you need
columnList is a colon separated list of the columns that you want to total
You could even get more fancy and add different agregates (i.e. AVG, MIN, MAX etc.)
Example of this at the link below.
http://apps.htmldb.com/apps/f?p=htmldb:knowledgebase:::NO:RP:P5_ID:84315

The problem is that the totals may or may not be rendered on the page depending on the page size and the number of records in the result set - so with an Interactive Report, unless you force it to always show All Records, the page might not even be able to use JS tricks to move the summary line to the top.
My preference in this sort of situation is to add a separate region to the page based on a simple SQL query. It will be shown above the interactive report. Unfortunately the columns won't be aligned, however.

I found the solution
Add sub query to calculate the sum
Union with existed result
Use highlight function to make up the new row

Related

PL/SQL UTL_FILE package read from csv and load values into a table

If I have a CSV file like this:
How can I read this with UTL_FILE package and load the values into one table which have columns: ItemIdentifier, SoldOnWeb, SoldInTheShop?
From my point of view, as CSV files can be edited with MS Excel, I'd suggest you to rearrange the file and uniform it. The way it is now, it contains different headings and - to make it worse - they don't "match" (the same column contains itemidentifier and soldintheshop values; the same goes for the next column).
Add yet another column which would explain what the "sold..." column represents. Finally, you'd have something like this:
itemidentifier amount location
-------------- ------ -------------
1 10 soldOnWeb
2 7 soldOnWeb
3 5 soldOnweb
1 7 soldInTheShop
2 3 soldInTheShop
Doing so, it is a simple task to insert every value where it belongs.
Otherwise, can it be done in PL/SQL? Probably. Will it be difficult? Probably, as you have to "remember" what you're selecting in each row and - according to that - insert values into appropriate columns in the table.
You know how it goes ... garbage in, garbage out.

How to increase number of displayed rows in a tabular form using apex 5.0

Currently my tabular form displays 10 rows at a time. How do I increase the number of rows to be displayed, say from the current default number of 10 to something like 20? Is there a place somewhere in the page attribute where you can set the number of rows to be displayed, as in the case of an interactive report?
Region -> Attributes -> Layout -> Number of Rows
In scripting window you will find a drop-down with row label, select it and choose the number of rows you want to display.
If you are facing this problem for an 11g Oracle SQL Developer:
More than 10 rows available. Increase rows selector to view more rows.
Then you can directly solve this from drop down menu of rows situated beside Autocommit checkmark from SQL Workshop:
select 1000000 to show more rows :
Run those queries again!
Final Result having 21 rows in result :
This might have solve your problem!
You can call function
javascript:apex.widget.tabular.addRow();
N number of times per click... For example,
Generate 2 rows, call
javascript:apex.widget.tabular.addRow();
javascript:apex.widget.tabular.addRow();
Generate 4 rows, call
javascript:apex.widget.tabular.addRow();
javascript:apex.widget.tabular.addRow();
javascript:apex.widget.tabular.addRow();
javascript:apex.widget.tabular.addRow();

How to Load CSV file into Apex 5 for particular columns?

I have table with three columns x (Foreign Key),y(Primary Key),z and also csv file with only two columns data y,z as shown in images http://imgur.com/a/12ENZ (Please copy and paste link)which has to uploaded into table.Here I fill x column for all the rows with constant value ‘20’.i have used Data loading wizard to do this in Apex 5.
Problem:
In the first step I loaded this table and then In next step you can see that I have to do column mapping .Here I get only two columns y(Mileage),z(Ratio) because I have only two columns in the excel and first column x i want to map with null values here(Problem 1).
In the next step I have added process in the Datavalidation to update column x to fill that constant value as shown in images. But you could see p_attr_number =1 makes first column to be updated with 20 value.Here I need my first column x to be filled with constant value 20(Problem 2).Please Give me some suggestions on this for solving this problems.
for problem 1 you can choose x column as nullable yes by editing your colum in object browser -> your table -> modify column -> nullabe field to NULL (do not reguire a value) so when you upload data it will not fill third column if you map 2 columns (althıugh you do not see the column name in wizards)
for problem 2 i am assuming that all fields in your database has data so you you can add a page process for giving new values to the uploaded data which has null x columns
1 go to 4th page 'Data Load Results' which created by data wizard
2 click add a page process button
3 choose pl/sql
4 give a name and choose on submit - after computations and validations
5 enter an update command which suits your needs as below
update your_table_name
set
x=20
where x is null;
6 write your success messages
7 choose finish button in option "when button presses"
8 create process
9 add a Branch button in Branches
10 give a name click next
11 enter the page you want to go after data load
12 choose finish button in option "when button presses"
13 go to finish button and choose submit in Action When Button Clicked -> action
by adding this process and branch
1st system will insert data to table
2nd it will update all the null x values to the static values in your table
3rd it will return to the page you want

How to Repeat table in one report side

I have a simple report (1 Table with 2 small columns)
the report works fine but now I'm trying to repeat the table on the same page but I can't find an example on how to do this.
I also crosses only one question about this problem, so maybe I miss something obviously on how to solve this.
Could somebody please enlight me?
You can 'play' with (a single) Tablix details to simulate table repetition.
For example you can create 3 rows of details like this:
row 1: header
row 2: value
row 3: footer space
To obtain a result like this:
You can also use a different layout, for example:
row 1: label/value for column 1
row 2: label/value for column 2
row 3: footer space
If you have a very small table you can also set report columns to fill horizontal space.
This is the result (simulating table repetitions but you can also use a simple Tablix with standard header/details):
This is the result if you use columns and a simple Tablix with standard header/details:

How do I show blank entries on a BIRT Table sub-group?

I am trying to create a table with two groups in a BIRT report.
I first group by year, and then by a criteria in a second column. Let's say this criteria is one of [A, B, C, D]. If there doesn't exist a criteria for a year, the default in BIRT is for it to be blank. For example, if 2011 didn't have any B or D criteria, my report would look like:
2010
----
A 1
B 2
C 3
D 4
2011
----
A 5
C 6
However, I want all the possible criteria to show up, even if they don't have any entries for a particular year.
I tried setting the property under advanced->section->show if blank = true, but that didn't do anything.
Any ideas?
(I am using birt 2.6.0)
The SQL query (connecting to a mysql datasource) is fairly simple:
SELECT year_field, decision_field, sales_field
FROM databaseName
The report is http://bit.ly/9SDbNI
And produces a report like:
As I commented earlier, this is a dataset issue, not a BIRT issue. The issue is that the dataset does not include rows where there were no sales for those decision codes, in those years.
I was rather hoping there would be separate tables for the years and decision codes, but it looks as though there's a single table for everything. Therefore, I suggest the following query (based on the query in the rptdesign file, rather than the question):
select y.year_field, d.decision_field, t.sales_field
from
(select distinct year_field from databaseTable) y
cross join (select distinct decision_field from databaseTable) d
left join databaseTable t
on y.year_field = t.year_field and d.decision_field = t.decision_field
Also, change the definition of the Count column to be a count of the sales field, rather than the decision field.
I noticed that you are using MySql. Use SELECT IFNULL(<MyCol>,0) from my_table; to replace the null values with 0.

Resources