It would be realy helpfull to have an option in the grid to show summaries as a last line. As it is absolutelly required in my app I built the following function:

function getSum(pDatasource in varchar2, pColumn in varchar2) return number is fRows api_datasource.tt_rows; fSum number := 0; begin api_datasource.getRows(pDatasource, fRows); for i in 1..fRows.count loop fSum := fSum + nvl(fRows(i)(pColumn).value_nr, 0); end loop; return fSum; end;

This function is called by an action each time the corresponding field is updated, and of course when the panel is shown to get the first time the totals.

It is not thoughfully tested and it has many flows (i.e it doesn't check for field existance or datatype etc), but at least it works.

Can you please confirm that is a valid way to get summaries?

Thank you.

asked 03 Oct '12, 09:19

Vlisidis%20Akis's gravatar image

Vlisidis Akis
163119
accept rate: 5%


Hi Vlisidis,

Yes, your method is a valid way to get summaries. However, you can achieve the same functionality in a more efficient way using the api_datasource.getQuery API. This API is especially useful when you need to get a subset of the datasource row set or when you neeed to perform some calculations over the datasource row set;

function getSum(pDatasource in varchar2, pColumn in varchar2) return number is
   fSum number;
begin
  execute immediate
     'select sum(' || pColumn || ')
      from ' || api_datasource.getQuery(pDatasource)
   into fSum;
  return nvl(fSum, 0);
end;

Also, you may need to call this function when a datasource row is deleted.

Regards, Ibrahim

link

answered 03 Oct '12, 15:11

Ibrahim%20Sandalli's gravatar image

Ibrahim Sand... ♦♦
1.5k5
accept rate: 25%

Hi Ibrahim, Thank you for the hint, but I think that by querying the table it will not show the changes the user is making in the grid before commiting the results. I will try your method.

Regards, Akis

link

answered 03 Oct '12, 21:43

Vlisidis%20Akis's gravatar image

Vlisidis Akis
163119
accept rate: 5%

Hi Vlisidis,

api_datasource.getQuery API allows you to query the datasource table (dsi table) where the user changes are applied. Therefore, you will be able to show the changes before commiting the results.

Regards, Ibrahim

(03 Oct '12, 22:59) Ibrahim Sand... ♦♦

Very very usefull comment. I will try it. Thank you Ibrahim.

(04 Oct '12, 00:16) Vlisidis Akis
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×85
×1

Asked: 03 Oct '12, 09:19

Seen: 1,450 times

Last updated: 04 Oct '12, 00:16


© Copyright Gerger 2017