Accessing Apex_application.g_fXX values from a stored procedure - oracle-apex

I woul like to access Apex_application.g_fXX values from within the database stored procedure, either by passing the whole array as an input parameter or by reading session state from within the database. Is this possible? My reason for trying to do this is that I want to move all heavy processing to the database.
TIA, Tamas

Sure, why wouldn't it work?
CREATE OR REPLACE PACKAGE "APXPA_TEST" IS
PROCEDURE process_something;
PROCEDURE process_something2(i_values IN apex_application_global.vc_arr2);
END "APXPA_TEST";
/
CREATE OR REPLACE PACKAGE BODY "APXPA_TEST" IS
PROCEDURE process_something
IS
BEGIN
FOR i in 1..apex_application.g_F02.COUNT
LOOP
apex_debug_message.log_message('processing '||apex_application.g_f02(i)||'...');
END LOOP;
END;
PROCEDURE process_something2(i_values IN apex_application_global.vc_arr2)
IS
BEGIN
FOR i IN 1..i_values.COUNT
LOOP
apex_debug_message.log_message('processing '||i_values(i)||'...');
END LOOP;
END;
end "APXPA_TEST";
/
I made a page with a tabular form based on EMP. I created a page process with process point On Submit - After Computations and Validations, before the MRU.
apxpa_test.process_something;
apxpa_test.process_something2(apex_application.g_f02);
G_F02 holds ENAME
Now run the page and enable debug. Then just submit the form (you don't need to edit anything), and go to view debug. Pick the last entry. Scroll to the point where it goes over the page processes: you'll see the output there. (i only used deptartment 10)
Processes - point: AFTER_SUBMIT
...Process "some process" - Type: PLSQL
...Execute Statement: begin apxpa_test.process_something; apxpa_test.process_something2(apex_application.g_f02); end;
processing KING...
processing CLARK...
processing MILLER...
processing KING...
processing CLARK...
processing MILLER...
...Process "ApplyMRU" - Type: MULTI_ROW_UPDATE
...Process "ApplyMRD" - Type: MULTI_ROW_DELETE

Related

Camunda, how to inject subprocess with specific parameters from main process

I have a Camunda flow with a Call Activity (sequential), the call Activity calls several subflows based on a list of process keys (ids) in a certain order.
For instance I get a list of ["flow-1", "flow-2"], then flow-1.bpmn and flow-2.bpmn are executed.
But, also in the scope is flow specific data, added to the scope in "Read LOT Configuration". For instance [{"name", "flow-1", "identifier" : "some-data"}, {name: "flow-2", "identifier" : "some other data"}].
I would like the call activity to determine that for flow-1, I need to send the flow-1 related object along.
I do not want to send the entire collection, but only the flow specific data.
How can I achieve this?
Some ideas:
a) use the element variable from the call activity settings as key to extract the correct data element in a data mapping
b) surround the call activity with a multi-instance embedded sub process. In this scope you will have the element variable (processId), which can then be used to perform delegate variable mapping (https://docs.camunda.org/manual/7.16/reference/bpmn20/subprocesses/call-activity/#delegation-of-variable-mapping)
c) pass the processID as data and fetch the configuration for the particular process inside its sub process implementation only

Power Query | Loop with delay

I'm new to PQ and trying to do following:
Get updates from server
Transform it.
Post data back.
While code works just fine i'd like it to be performed each N minutes until application closure.
Also LastMessageId variable should be revaluated after each call of GetUpdates() and i need to somehow call GetUpdates() again with it.
I've tried Function.InvokeAfter but didn't get how to run it more than once.
Recursion blow stack out ofc.
The only solution i see is to use List.Generate but struggle to understand how it can be used with delay.
let
//Get list of records
GetUpdates = (optional offset as number) as list => 1,
Updates = GetUpdates(),
// Store last update_id
LastMessageId = List.Last(Updates)[update_id],
// Prepare and response
Process = (item as record) as record =>
// Map Process function to each item in the list of records
Map = List.Transform(Updates, each Process(_))
in
Map
PowerBI does not support continuous automatic re-loading of data in the desktop.
Online, you can enforce a refresh as fast as 15 minutes using direct query1
Alternative methods:
You could do this in Excel and use VBA to re-execute the query on a schedule
Streaming data in PowerBI2
Streaming data with Flow and PowerBI3
1: Supported DirectQuery Sources
2: Realtime Streaming in PowerBI
3: Streaming data with Flow
4: Don't forget to enable historic logging!

apex_application.g_print_success_message variable does not get set

On my DML form I have a delete process that calls a PL/SQL function:
DECLARE
err_code NUMBER;
BEGIN
my_package.delete_record(id => :P2_ID,error_code => err_code);
IF NVL(TO_NUMBER(err_code),0) = 0 THEN
apex_debug.message('Record deleted');
apex_application.g_print_success_message := 'Record deleted';
END IF;
END;
Somehow apex_application.g_print_success_message does not get set and displayed even though everything else works as I see a debug message being written. Can anyone help my figure this one out? Could it be because I have multiple processes on the page?
Check for the process point of yout page process, the success message won't appear on a "Before Header" process point.
If that doesn't help, check out the apex.message API.
apex.message.showPageSuccess( "Record deleted" );
Only the last assignment are shown.
So check if you have an empty assignment to it somewhere else.
apex_application.g_print_success_message:='';
Also see if you by any chance have filled in a space in one of the page processes "Success Message"
Updating that variable directly is not supported.
You can define a hidden item, set that within your processes
:P0_MY_HIDDEN_ITEM := 'Process outcome';
Then include the following in the success message attribute to your final process.
Errors can be added using apex_error package.

Selenium Python Script, InvalidElementStateException

So I'm getting this error every so often when running the exact same test.
StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
(Session info: chrome=69.0.3497.100)
(Driver info: chromedriver=2.41.578706 (5f725d1b4f0a4acbf5259df887244095596231db),platform=Mac OS X 10.12.6 x86_64)
The only problem is that it seems to happen inconsistently to different areas of the code. It's when trying to access DOM elements, like a search field, of my ReactJS page. I'm running this through ROBOT Automation Framework, using a mix of the SeleniumLibrary and a custom library.
I've read that it's simply as it sounds, the xPath as become outdated on the DOM, but that doesn't help me figure out why it's an inconsistent error happening almost anywhere at any point.
EDIT: It seems to be happening in this:
def filter_modality(self, filter):
filter_value = '//span[#title="{}"]//parent::li'.format(filter)
self.selib.click_element(filter_locator)
self.selib.wait_until_page_contains_element('//*[#class="multi-selector-options open"]')
self.selib.wait_until_element_is_visible(filter_value)
self.selib.click_element(filter_value )
self.selib.wait_until_page_contains_element('//div...[#class="option selector-item active"]',
error=("Could not select filter: {}".format(filter_value )))
#I get the stale element message from or after executing this click_element
self.selib.click_element(filter_locator)
self.selib.wait_until_page_does_not_contain_element('//*[#class="multi-selector-options open"]',
error="Filter dropdown did not disappear after selection")
The exception comes when SE has found an element, but shortly afterwards something (a JS function) has changed it - removed from/rearranged it in the DOM, or changed its attributes significantly, so it's no longer tracked as the same element.
This comes for the fact that SE builds an internal cache of the DOM, which may become desynchronized from the actual one; thus the name "stale" - the el. is cached in some state, but its actual form is now different.
The issue is that common, that there is a specific SO tag for it - https://stackoverflow.com/questions/tagged/staleelementreferenceexception (I myself was surprised from this).
The common solutions are:
sleep for some seconds before an event you know will cause the issue
re-get an element before its usage (if you store a reference to it in a WebElement object, not really the case with robotframework)
have a rertry mechanism on working with an element that you know may cause the execution
swallow the exception and move along (I've done it in a few places, where the element was just a confirmation an operation was executed - it has been shown/found by SE once, afterwards I don't care is it changed in the DOM)

How to give link for users to Download the Csv Template in Apex

I have an requirement to give link to users in Apex Application to download the csv template.
I have created a link and created an process code as below for the users to download the csv file, But its showing some json error,
begin
-- Set the MIME type
owa_util.mime_header( 'application/octet', FALSE );
-- Set the name of the file
htp.p('Content-Disposition: attachment; filename="test.csv"');
-- Close the HTTP Header
owa_util.http_header_close;
-- Loop through all rows in EMP
for x in (select WORKSPACE,GROUPNAME,MEMBERS from CSV_NON_DYNAMIC_TEMPLATE where FILENAME='test.csv')
loop
-- Print out a portion of a row,
-- separated by commas and ended by a CR
htp.prn(x.WORKSPACE ||','|| x.GROUPNAME ||','||x.MEMBERS|| chr(13));
end loop;
-- Send an error code so that the
-- rest of the HTML does not render
htmldb_application.g_unrecoverable_error := true;
end;
Even i code the process code to on load process, then its working the excel is creating but other than that no buttons or process code not working on the same page.
thanks
First, saying you're getting "some json error" is not helpful. It helps to put the exact error message you're getting in your question.
Second, you probably have this process running at the Process step. Apex is submitting the page via Ajax, your process runs, returns an error to the page and you're getting your message.
Change your process to run at the Before Header point and change it so it has a server side condition of "Request = Value" and make the value "DOWNLOAD".
Change your button's action to Redirect to Page In This Application, and set the link to your page number with a request of "DOWNLOAD" (that's under the advanced section).