Dynamically update a number field by summing the values of the other number fields on the same page - oracle

I've been struggling to dynamically update a number field in my Apex application with the sum of values from the other number fields on the same page. The page contains a questionnaire with 6 questions that have predefined answers, along with a predefined number score for each answer. At the bottom of the page I have a number field labeled "Score" that I want to be updated depending on the answers chosen.
I've went ahead and created a dynamic action that is supposed to update a number field named P3_SCORE.
The example I've been trying to get to work adds two of the items at the moment, number field item P3_SELFCARE and P3_MOBILITY.
BEGIN
return :P3_SELFCARE + P3_MOBILITY;
END;
I keep getting errors with my PL/SQL Function Body.

Don't know what the errors you're getting are, but don't you want
BEGIN
return :P3_SELFCARE + :P3_MOBILITY;
END;

Related

how to add one more data block item in oracle forms [duplicate]

In the below given example like rejection date it has total 5 rows of same type.
when i tried to create new data block item like issue date(issue date is table column) I'm getting only one row (I want to get 5 rows as shown below.)
Forms does that itself, but you have to add that new item into that block. Because, it is
block's Number of records displayed property
item's Number if items displayed property
that affect number of "rows" you'll see.
For example, if block's number of records displayed is set to 5 (as it apparently is) and you add a new item to that block and set appropriate canvas, Forms will create 5 instances of that item. You can then choose not to display all of them but any number between 0 and 5 (where "0" also means "all of them" (5 in this case)).

Limiting rows initially returned in select list

Populating an Apex 5.1 select list of employees with about 25,000 names is proving to be a performance problem when loading the page. Is there a method of limiting the initial list to a set number (such as 200), and dynamically populating with chunks of additional names as the user scrolls through the list? Are there other options I should consider that would not slow down the page load?
I am currently using a dynamic LOV, and have tried adjusting this LOV to include Oracle row limiting code; however, there is no way of fetching past the initial set of rows. The source of the data is a view on a materialized view.
I appreciate any ideas
I'd use a pop-up LOV with a search function, not showing any records until the user enters a search value (more than 3 characters). I know it's tedious to use a pop-up LOV but it seems the only way to prevent waiting for a slow list to display.
I'd try with cascading lists of values. I don't know what those 25.000 names represent, but - suppose it is a large company. Then you'd
1st LoV: continent
2nd Lov: country
which refers to the previous LoV as where country.continent = :P1_CONTINENT
3rd LoV: city
which refers the previous LoV as where city.coutry = :P1_COUNTRY
4rd Lov is actually your current query:
which refers to the previous Lov as where person.city = :P1_CITY
Now your list of values wouldn't contain 25.000 rows, but - hopefully - a lot less.

Build a view-sum row programmatically in Drupal 8

I have a table view with two numeric fields and some rows.
First task is, to build a third field where the two fields are multiplicated.
It is no problem for me, to build the sum with views_pre_render(\Drupal\views\ViewExecutable $view).
But i don't find a solution to get this new field in frontend.
Should I overwrite a given field of the node in view or should i build a new field?
And the second task is, to build a sum over all rows of the new field an output it in footer.
I am seeking for ours the different view-hooks in API but don't find the solution.
Could you please give me some hints?
I put a new field to the content type with default 0.
And with mymodule_entity_presave(Drupal\Core\Entity\EntityInterface $entity) i did the multiplication of the other two fields and updated the new field with this value.
Put the new field to view and now I have the multiplicated value.
Next step is to build a sum row with total sum of the new field.
I would like to build a new Variable for Twig with a preprocess view-Function.
I tried this one mytheme_preprocess_views_view_table(&$variables), becaus it is a table view.
But i cant get the raw value in the foreach loop of the result.
What would be the best solution?

Oracle APEX | How to change select list value and Submit it dynamically

I have two select lists
1. The first one P4_country_id_B contains countries names
select country_name as d, country_id as r
from countries
2. The second one P4_CITY_ID_B contains cities of a country based on selected value in P4_CITY_ID_B.
select city_name as d, city_id as r
from cities
where country_id = :P4_country_id_B
Everything goes OK without any problem.
BUT
I use Execute PL/SQL Code Dynamic Action to change selected values of those lists like this (for example):
:P4_country_id_B:=country_returned_value;
:P4_CITY_ID_B:=city_returned_value;
Where
country_returned_value : is a one value of countries list values for example (USA)
city_returned_value : is a one value of cities list values for example (NewYourk).
The first selected list value changes but the second list never changes.
Notes:
I used P4_country_id_B,P4_CITY_ID_B as Page Items to Submit for the dynamic action.
I don't whan to submit the page instead of dynamic action
How can I change list values in this case please?.
Thanks in advance.
Cascading select lists are refreshed through ajax.
Change select list 1, select list 2 will be refreshed.
You execute plsql, which in turn will set the value of the items involved. Both are select lists, and one is dependent on the other.
So while both will be set, the change of the first one will cause the second to be refreshed.
In other words, you're doing it too fast. And while there is a solution, the proper way is a bit complex and I wouldn't build it in DA's personally.
You haven't specified how or when you call the code which sets the values for the items. So here I'll just assume a DA with an action of type "Execute JavaScript" (for example)
// perform a call to the ajax callback process to get the country and city id
// there are several ways to provide values to the process if necessary.
// for example through x01, which can be used in the proces like
// apex_application.g_x01
apex.server.process('GET_COUNTRY_DEFAULTS', {x01:""}).done(function(data){
// process returns JSON which contains 2 properties: country_id and city_id
// data.country_id
// data.city_id
// bind a ONE-TIME handler to the after refresh event of the city
// cascading LOVs fire the before and after refresh events like any other
// refreshable element in apex
// a one time handler since the values are different each time this code will
// execute
apex.jQuery("#Px_CITY_ID").one("apexafterrefresh",function(){
// after refresh of the list, attempt to set the value of the list to the
// value retrieved earlier
apex.item(this).setValue(data.city_id);
});
// finally, set the value of the country. Doing this will also trigger the
// refresh of dependent elements
apex.item('Px_CITY_ID').setValue(data.country_id);
// since a handler has been bound, the refresh will occur, the after refresh
// triggers, and the value will be set properly
});
Finally, create a new process on the page under "AJAX Callback", and name it GET_COUNTRY_DEFAULTS
DECLARE
l_country_id NUMBER;
l_city_id NUMBER;
BEGIN
l_country_id := 8;
l_city_id := 789;
htp.p('{"country_id":'||l_country_id||',"city_id":'||l_city_id||'}');
EXCEPTION WHEN OTHERS THEN
-- returning an error while using apex.server.process will prompt the user
-- with the error and halt further processing
htp.p('{"error":"'||sqlerrm||'"}');
END;
That should tie everything together.
I think there is some confusion here. My answer below, assumes, according to your question, the first list name is P4_country_id_B, and the second list name is Cities_LOV. If that is not the case, please clarify.
Your first list called P4_country_id_B, and you assign it to itself through the following statement:
:P4_country_id_B:=country_returned_value;
So basically, nothing has changed, the value of P4_country_id_B is the returned value of your list P4_country_id_B without any need for this assignment. Note, it is not clear to me, what is country_returned_value, because P4_country_id_B holds the returned value.
Secondly, you have a list called Cities_LOV, and you assign the returned value to P4_CITY_ID_B page item, through the following statement:
:P4_CITY_ID_B:=returned_city_value;
Again, I am not sure what is returned_city_value, because Cities_LOV holds the returned value of that list.
I am not sure what you are trying to achieve here. But I assume, you want to allow the user to select the Country first, and then based on that, you want to refresh the Cities list to display the cities in that particular country. If that is the case, then use a dynamic action on P4_country_id_B value change, to refresh the value of Cities_LOV. You only need to pass P4_country_id_B to that dynamic action.
UPDATE
After you corrected the wording of the question, the answer would be like this:
In your child list P4_CITY_ID_B make sure you set the option Cascading LOV parent item(s) to the parent list P4_country_id_B. You do not need the dynamic action. The child list, should refresh upon the change of the parent list. The answer here, goes in details about how to implement cascading list

Visual Studio 2005 table rendering order

I'm working in Visual Studio 2005 Reporting and I'm trying to implement a workaround of nesting aggregate functions (I need to perform a Count of Sums). In the table details row, I have a call to custom code to increment an integer every time the value of one cell is >10, then the footer has a call to a custom code function that just returns that value.
The count was always returned as 0, so I threw in some MsgBox calls and noticed the table footer is being called before the details rows. I need the table details rows to be called first so that the "get" function in the footer will actually retrieve the value I need.
To be more specific, I'm looking to count the number of times a given table cell, whose value is calculated as (Sum / (Sum+Sum+Sum)) * 100, is greater than 10. Since aggregate functions can't be nested, and the use of aggregates on ReportItems!... can only be done in report headers/footers (in my case not helpful as it will display a different total on each page), I'm left with the option of custom code.
Is there any way to force the details row of a table to be rendered before the table footer?
Instead of using the table footer, I used a textbox beneath the table, so the table was rendered first, header and details rows, then the report processed the textbox below, leading to the correct value.
Hope that helps anyone that comes across this issue.

Resources