Cascading select list default value not set Oracle Apex - oracle

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.

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).

Oracle apex apex_application.g_f0x don't get table items

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.

How does bind variable substitution work for page Items in ORACLE APEX

I was wondering how does ORACLE APEX identify if a certain page item value should go as number or varchar2 when used in stored procedure call.
my_pkg.proc1(P1 =>:P2_ITEM1);
Here, how does APEX engine identify if the parameter P1 for proc1 is expecting a number or varchar2 or date.
To extend:
I have a grid. With query as below
Select * from table(my_pkg.pipe_func(:P2_PARAM1,:P2_PARAM2));
When user clicks a button I need to get the current session state value of these bind substitutions and I want to store above select query in a table as
Select * from table(my_pkg.pipe_func('ParamVal',256));
How can this be achieved?
It's the Oracle database that does this grunt work, in the same way it's done it for years. You can see this in the v$sqlarea.
And you should explicity convert these bind variables, as they will be inheretly treated as a varchar - same as they're stored.
where id = to_number(:p1_id)
And from an APEX perspective, if the user changes a value on screen, and you invoke a dynamic action to refresh a region using those items - you should list them in the 'Page items to submit' attribute, just under the region SQL. This will ensure the database session state is updated with what's in the browser, before conducting the refresh.

Oracle APEX Selection list

I have a form on a table with some values (text fields) and a select list. The select list is declared in shared components and shows me values from another table. Also I have some process (after submit) to modify and create new table entry. Everything works fine without propagating values from select list. There are no errors from the process. It looks like the process didn't get a value for :P22_WORKER_LIST from the selection list. It should work when I push the create or save buttons but nothing happened. Every instruction in BEGIN END block runs great without this one.
Process:
BEGIN
<some instructions>
UPDATE "WORKER" SET ACCOUNT_LOGIN = :P22_LOGIN
WHERE SURNAME = :P22_WORKER_LIST;
END;
Thank you for suggestion with the session state. After submiting page it turned out that the value for my :P22_WORKER_LIST is a WORKER_ID instead a SURNAME.
BEGIN
<some instructions>
UPDATE "WORKER" SET ACCOUNT_LOGIN = :P22_LOGIN
WHERE WORKER_ID = :P22_WORKER_LIST;
END;

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';

Resources