The interplay between javascript and PL/SQL tasks in a dynamic scenario

I'm attempting to run multiple pl/sql blocks within a Dynamic Action, providing real-time feedback to the user through a modal dialog displaying the current status.

Here is an example of what I am trying to achieve:

Processing Step 1...

/*Run pl/sql code for step 1*/

Processing Step 2...

/*Run pl/sql code for Step 2*/

and so forth...

While both the pl/sql and javascript codes work individually, when combined in a Dynamic Action with the following sequence:

1 - Execute Javascript

2 - Execute PL/SQL block /* With wait for result option checked*/

3 - Execute Javascript

4 - Execute PL/SQL block

The status dialog does not appear, however the pl/sql blocks execute without any issues.

I suspect this may be related to javascript not being multithreaded, so I attempted moving the pl/sql blocks to application processes and executing them as ajax calls like so:

function something(){
    var get;
    var result = 0;
    updateStatus('Running Step1');
    get = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=P6_STEP_1',0);
    result = get.get();
    if(result > 0){
        updateStatus('Running Step 2');
        get = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=P6_STEP_2',0);
        result = get.get();
    }
    closeStatusDialog();
}

However, even with this change, the processes execute correctly but the dialog still does not show up. Finally, I added a setTimeOut function to each call, as follows:

function something(){
    var get;
    var result = 0;
    updateStatus('Running Step1');
    get = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=P6_STEP_1',0);
    result = setTimeOut(get.get(),500);
    if(result > 0){
        updateStatus('Running Step 2');
        get = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=P6_STEP_2',0);
        result = setTimeOut(get.get(),500);
    }
    closeStatusDialog();
}

Despite these changes, the issue persists. What steps can I take to ensure proper functionality?.

I have reviewed the browser console and no exceptions are being thrown, likewise with the pl/sql blocks.

Answer №1

I've successfully resolved the issue using javascript and application processes, without relying on dynamic actions. This post is intended to assist others facing a similar problem.

The htmldb_Get Javascript object serves as an oracle-apex wrapper for the XMLHttpRequest AJAX object, despite being poorly documented.

Upon examining the code (provided at the bottom), I discovered another function named GetAsync. This function enables passing a function as a parameter to assign it to the onreadystatechange attribute of the XMLHttpRequest object. Consequently, this function executes each time the readyState attribute of the underlying XMLHttpRequest changes.

The function passed as a parameter should not have parameters in its own definition.

Instead of invoking get() on the htmldb_Get object, one should call GetAsync(someFunction)

In my particular case, this solution worked:

function something(){
    var get;
    get = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=P6_STEP_1',0);
    get.GetAsync(someFunctionStep1);
}

// Insert provided example functions here

At the end of the code snippet lies the definition of htmldb_get, including the GetAsync function

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Visualizing Data with d3.js Force Chart: Integrating Images with Nodes for Dynamic Animation

After enhancing a force diagram to compare two profiles, I am faced with the challenge of getting the main node to display an image. View comparison here How can I centrally align and size the image correctly while making the thumbnail data from the JSO ...

Discovering the following element containing an ID attribute with jQuery

Upon clicking a link, my goal is to locate the subsequent <section> with an ID attribute and retrieve its ID. In the provided code snippet and JavaScript function, the expected outcome upon clicking the link is for "section_3" to be logged in the co ...

What is the most secure method for conditionally wrapping input with state?

I used to check for errors and wrap the input and error message in a div conditionally. However, I faced an issue where the input would lose focus when re-rendered. Is there a way to wrap the input conditionally without losing focus on re-render if the err ...

How to retrieve the type of a computed keyof T as a generic type within TypeScript

I am working with two different interfaces: interface PersonRequirements{ user:string, password:string, id:number } export interface Requirement<R> { name: keyof R & string, save: () => any,/* I want this return type to be ...

Attempting to incorporate Font-Awesome Icons into the navigation bar tabs

As a newcomer to React, I've been attempting to incorporate Font Awesome icons into my secondary navigation bar. Despite using switch-case statements to iterate through each element, all the icons ended up looking the same, indicating that only the de ...

Encountered an issue with reading null properties when trying to access 'defaultPrevented' in bootstrap 5 toast

Implementing a custom hook to display and hide toast messages is working perfectly fine when invoking showToast in the button component of the Toast, but encountering an error when using this hook outside, for example in the button component of the App. Ty ...

Preflight request rejection due to access control check failure in React and Express

I am facing a similar issue to this question, but my problem is specific to using Express with React on the frontend. The error I am encountering is: https://i.sstatic.net/1OIfy.png Access to fetch at 'http://localhost:8000/api/users/auth/github& ...

In the middleware, the request body is empty, but in the controller, it contains content

Below is my server.js file: import express from "express"; import mongoose from "mongoose"; import productRouter from "./routers/productRouter.js"; import dotenv from "dotenv"; dotenv.config(); const app = expres ...

Streaming the request body in NodeJS using ExpressJS without buffering

Looking for a solution to process requests with no specified content-type as binary files. const app = express(); app.use(bodyParser.raw({type: (req) => !req.headers['content-type'], limit: '500mb' })); Some of these files can be ...

Effortless Form Filling using PHP Ajax

There are two text fields on my form: no_id and customer_name. As the user types in no_id, customer_name is automatically populated. Form <form> <input type="text" name="no_id" onkeyup="autofill()" id="no_id"> <input type="text" name=" ...

Using jQuery and Ajax to dynamically populate a select input with items upon page initialization

I am facing an issue with 2 <select> inputs: <select id="country"> <option value="" selected>Choose</option> <option value="usa">USA</option> <option value="uk">UK</option> </select> <select ...

Failure of Ajax to populate dropdowns in Internet Explorer

I've been grappling with some code for the past couple of days and I'm stuck. I really need some help. Here's what I'm trying to achieve: Manually fill the first dropdown menu Retrieve the selected value from the first dropdown, use i ...

Tips on how to showcase the current time in the local timezone on Next.js without encountering the error message "Text content does not match server-rendered HTML."

Currently, I am sharpening my Next.js skills by building a blog. My current challenge involves formatting a static ISO time string (which represents the creation time of blog posts) to match the local timezone of the user. <div className='post-time ...

Tips for effectively utilizing innerHTML in this particular scenario

For an assignment, we were tasked with creating a Madlib game where users input words into textfields to replace certain words in a hidden paragraph within the HTML using JavaScript and CSS. The paragraph embedded in the HTML page is as follows: <span ...

What purpose does the symbol '$' serve in React component properties?

While delving into the world of styled-component, I encountered some difficulties with the 'adapting based on props' aspect. import './App.css'; import styled from 'styled-components' const PrimaryButton = styled.button` co ...

How to make an Ajax request in Osclass classified script using a PHP file located in the theme directory?

Currently, I am utilizing the Osclass classified script and attempting to display a message that is returned by an ajax call. Within my theme folder, there is a file called ajax-test.php with the following content: <?php $name = $_GET["name"]; echo "My ...

When using a form_tag with the remote:true attribute, the Ajax functionality seems to be

I have a view_file that displays details of a specific 'Ad'. I would like to include a rating div and a form_tag within this page. How can I achieve this and integrate AJAX for form submission? Any guidance would be greatly appreciated. Thank you ...

Can I obtain a link through the branch_match_id parameter?

Within my application, there exists a hyperlink: hxxp://get.livesoccer.io/IuKk/0CRq5vArLx which leads to the following destination: hxxp://livesoccer.io/news.html?url=http%3A%2F%2Fwww.90min.com%2Fembed%2Fposts%2F4003374-chelsea-star-pedro-loving-life-at-s ...

Determining data using the AngularJS Slider component

I am currently utilizing the angularJS slider from this source: https://github.com/venturocket/angular-slider The sliders are functioning correctly, but now I need to extract the values from them for basic calculations. The HTML code snippet is as follo ...

I'm unsure how to utilize the generic type in this particular scenario. It's a bit confusing to me

Recently, I delved into TypeScript generics and applied them in specific scenarios. However, I encountered some challenges. While working with two different interfaces, I faced a need for flexibility. For instance, I needed to make server requests. func ...