Oracle apex apex_application.g_f0x don't get table items - oracle

I have a report with apex_item(s). The report is complicated so I show only what is relevant for simplification.
The report is created with:
select ID || apex_item.hidden(11,ID) as "ID",
apex_item.text(p_idx => 12, p_value => VOLUME) as "Volume"
from TEMP;
That gives:
On submit page, I have a process that counts the report rows (later I loop on this rows to do some action):
apex_debug.warn('count f11: ' || apex_application.g_f11.count);
The result is 2 as expected.
The problem - when I try to save changes from the report without submitting the page:
I have a button "update server" which have a dynamic action on click with PL/SQL action:
The PL/SQL contains exactly the same code as the loop above but the result is now 0.
My goal is to make actions based on the rows. without submitting the page, But I can't understand how can I loop this rows without submit.
Thanks

When you're running a Dynamic Action of the type Execute PL/SQL Code (now called "Execute Server-side Code"), you can specify page items to be submitted with the action that will be set in session state before the PL/SQL block runs, but I don't think you can specify those fxx whatever they're called type of items. I think you have two options:
Create a hidden item and populate that with a Javascript action that runs before your PL/SQL action, then submit that hidden item along with your PL/SQL action.
Change your PL/SQL code to an Ajax Callback process, then invoke it with apex.server.process in a Javascript DA. You can specify fxx type items to submit with that call.

Related

I don't know why the pl/sql does not use the value of the item

My Apex application has one main page where the user can see all entries, if he want to change he clicks on the left button and go to the detail side.
The main page
If the user load the detail page a dynamic action Starts and the PL/SQL Function body do his job.
declare
v_DB_ZAUE number;
begin
SELECT COUNT(*) INTO v_DB_ZAUE FROM DB_ZAUE WHERE CCB_ID = :P21_CCB_ID;
return v_DB_ZAUE;
end;
Now starts my problem, on the detail page is the value of the item P21_CCB_ID Displayed put the PL/SQL Code ignores it. Because if the PL/SQL Code works the field with the name Temp were 1 and not 0.
Here is the detail page
PS: I check the names of all variables there are all OK.
I presume you didn't put P21_CCB_ID into Dynamic Action's Items to Submit property, so I'd suggest you to do so.
Because, without it, P21_CCB_ID item's value isn't in session state so it (query) behaves as if it doesn't exist (or uses value that was previously put into session state, and that's not what you really want).

How to pass item value to oracle function in oracle application express?

I have item in oracle apex
P12_MOBILE_NUMBER
on form load I am fetching data using fetch row from and set to different items. Once mobile number set to item P12_MOBILE_NUMBER, I want to pass its item value to oracle function and function returned value set to P12_MOBILE_NUMBER again .
I can call my function like
Select stars(mobile_number)as mobile_number from dual;
Please help me out how can I do that , I am using application express 18.2
Create a Page Load dynamic action:
set its True action to "Execute PL/SQL Code"
that code would be
:P12_MOBILE_NUMBER := stars(:P12_MOBILE_NUMBER);
Items to submit: P12_MOBILE_NUMBER
Items to return: P12_MOBILE_NUMBER
Run the page; automatic row fetch will fetch row value, and page load dynamic action will modify the mobile number (based on what your function actually does).

Cascading select list default value not set Oracle Apex

Getting an issue with cascading select list. Default value of a cascading select list is not set, not being displayed.
I have a select list named P3_ENTITY that is cascading and having 3 parents: P3_APPLICATION, P3_SCHEMA_LIST and a checkbox P3_CATEGORY_CHECKBOX
I set the default value of P3_ENTITY in a Plsql process SET_VALUE that gets fired on page rendering.
Process code is like :
BEGIN
:P3_ENTITY := :F100_FILTER_ENTITY;
END;
Now P3_ENTITY select list takes time to be loaded at the time of page load, but as execution of process SET_VALUE becomes completed before load of P3_ENTITY select list, that default value gets overwritten by NULL after full load of that select list.
Please help.
Thanks in Advance.
To set cascading parents to a list implies that each time that the parents change, the list will be refreshed, this does not cause the re execution of the plsql block that you defined to set a default value.
What you could do, is create a dynamic action that execute your plsql block on an After Refresh basis, this means that once the refresh event is complete the dynamic action will assign the :F100_FILTER_ENTITY value again.

Refresh a Classic Report based on a collection

I am currently learning apex but got stuck.
I am using Oracle apex 4.2. My app consists of 2 reports. In first I am choosing some checkboxes and clicking button which fires DA with some js code and uses apex.server.process with AJAX Callback like in this link.
Next the "On Demand" process launches PL/SQL procedure (I know there is no reason for that, but I did it for learning purpose) which processes checked values and concatenates them into one clob which is then being added to collection.
So each time I am clicking the button, exactly 1 new clob is being added.
My second report just reads ALL clobs from collection, and I want to refresh it each time after I click the button without submitting all of the page content. I have added DA with a True Action: Refresh but it works with delay. When I first click it - nothing happens, on the second click the clob which was generated previously shows up in the report region and so on. I guess I need to submit collections value to session state but I have nothing to add to the reports "Page Items to Submit" option.
Not seeing "most recent" data
The only reason you would see "outdated" data is because you use an ajax call to update the collection. It's asynchronous!
Similar, the refresh is async too. The actions don't wait for eachother to complete.
It can go kind of like this:
collect the checkboxes and send them off to some process, which somewhere down the line will return me something
sometimes, it depends, the ajax call is fast enough to have finished before the region refresh occurs
refresh the region
other times, the ajax call has taken a bit longer, and the refresh has already occured
To solve this, you'll have to add something to your apex.server.process call: the refresh of the collection-based report should only occur when the callback has completed.
Firstly though: add a static report id to your collection-based report. Do this by editing it. Providing a static id allows for easier selection of the region through a selector.
apex.server.process('Process Checked Rows', {f01: arr_f01}).done(function(){
//do something when the callback has finished
//like triggering the refresh event on the report required
apex.jQuery("#your_report_static_id_goes_here").trigger("apexrefresh");
});
Now the report will only refresh when you're sure the checkboxes have been processed into the collection.
Using a clob for storing IDs
As I've pointed out in the comments, it makes no sense at all to use a clob to keep the selected IDs together. There's just no argument to make for it beside perhaps pure experimentation. Honestly, time better spent elsewhere if you want to experiment with CLOBs.
Collections are meant to be a Global Temporary Table replacement within the context of Apex sessions. Use them like you would use a table. Simply insert the IDs of the selected rows into the collection.
FOR i IN 1..apex_application.g_f01.count
LOOP
apex_collection.add_member
( p_collection_name => 'CHECKBOX_COLLECTION'
, p_n001 => apex_application.g_f01(i) --NOTE: using N001 here to store a numerical ID
);
END LOOP;
If you only want to have uniques then you can do that here by adding a select on the collection, or add a distinct in the query used to loop or select over the collection.
FOR i IN 1..apex_application.g_f01.count
LOOP
DECLARE
l_exists BINARY_INTEGER;
BEGIN
SELECT 1
INTO l_exists
FROM apex_collections
WHERE collection_name = 'CHECKBOX_COLLECTION'
AND n001 = apex_application.g_f01(i);
EXCEPTION WHEN no_data_found THEN
apex_collection.add_member
( p_collection_name => 'CHECKBOX_COLLECTION'
, p_n001 => apex_application.g_f01(i) --NOTE: using N001 here to store a numerical ID
);
END;
END LOOP;
You can then eeasily loop over the records in this collection or use it to limit rows in other queries (eg another report).
SELECT n001 selected_id
FROM apex_collections
WHERE collection_name = 'CHECKBOX_COLLECTION';

oracle apex select list

I'm using Oracle Apex 4.2. I have a select list. I'm trying to create a dynamic action that should be simple enough but I'm not sure how to do it. I'm also trying to insert selected value in database using plsql code but there some error occur.
lets say
How would I make this dynamic action?
Create item PX_SELECTLIST
Create dynamic action
Event = Change
Selection Type = Item(s)
Item(s) = PX_SELECTLIST
Create true action "Execute PL/SQL Code"
PL/SQL Code = Your PL/SQL code with begin end block - reference item value by :PX_SELECTLIST within the code.
Page Items to Submit = PX_SELECTLIST
Page Items to Return = leave it blank
Test it - each time value in PX_SELECTLIST changes the dynamic action is fired and PL/SQL code is executed.
Additionaly I suggest reading Oracle APEX docs - http://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/schema/42/dynactions/dynactions.html

Resources