Search This Blog

Sunday, October 23, 2022

Fetching and Parsing Data from Other Online Source To Oracle Database Using Web service in Oracle Apex

1. Create a table using the below code.

CREATE TABLE  "EMP_INFO" 
   ( "SERIAL" NUMBER, 
"GROUP_NAME" VARCHAR2(100), 
"EMP_NAME" VARCHAR2(100), 
"DESIGNATION" VARCHAR2(100), 
"MOBILE_NUMBER" VARCHAR2(20), 
"EMAIL_ADD" VARCHAR2(10)
)

2. Create a Page then Create a Region With Classic Report type. 

select * from EMP_INFO

3. Create a button like (Pull Data) to execute the process.

4. Create a Process and use the below code  

begin
insert into EMP_INFO
(SERIAL,GROUP_NAME,EMP_NAME,DESIGNATION,MOBILE_NUMBER,EMAIL_AD)select col001, col002, col003 , col004, col005, col006
from table
( apex_data_parser.parse
(  p_content=> apex_web_service.make_rest_request_b('https://raw.githubusercontent.com/Qaiums/Fatch-Data-From-Cloud-In-Oracle-Apex/main/emp_info.csv', 'GET')
, p_file_name=> 'emp_info.csv', p_skip_rows=> 1 )
);
end ;

5. Assign the button to execute the process. 


You can also Fetch and Parse from File Browser Item using APEX_DATA_PARSER. 

That's It...

Tuesday, October 18, 2022

API Calling From Oracle Apex Using JavaScript

1. Create a blank page then create a region.

2. Create two items (Like P46_URL and P46_RESPONSE) , One for inputting web service URL and another one is for getting response. 

3. Copy-pest the below JavaScript function into page propertice> Function and Global Variable Declaration 

function CALL_TO_WEBSERVICE()
{
 var urlvariable;
 var ItemJSON;
 var v_url = apex.item("P46_URL").getValue();
 URL = v_url ;  
 var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.send(ItemJSON);
$x("P46_RESPONSE").value = xmlhttp.responseText;

}

function callbackFunction(xmlhttp) 

{

 // alert(xmlhttp.responseXML);

}

4. Create a button and create a Dynamic Action on click event the button with Execute JavaScript Action. just call the function below. 

CALL_TO_WEBSERVICE();

5. That's All. Now just put the Web Service URL into the URL item and click on the button. 

Wednesday, October 12, 2022

Remove (Leave site? Changes you made may not be saved. Prevent this page from creating additional dialogs.) Warning Dialogs from Oracle Apex

In Oracle Apex whenever we move one page to another page then we may face this dialog warning. Sometimes it's good but sometimes users feel bored. 

So here we see how to remove this warning dialog?

Leave site? 

Changes you made may not be saved.

𐄂 Prevent this page from creating additional dialogs.

Solution:

Goto page properties> Navigation Menu> Warn on Unsaved Changes > Disable it.

That's it. 



Tuesday, October 11, 2022

Real Time Notification in Oracle Apex Using Ajax Callback Process.

Run time notification in oracle apex. Here it shows only one page. But you can do it globally for getting notifications from any page. 

1. Create a Table For Notification

 CREATE TABLE "NOTIFICATION_TABLE"  

 ( "PID" NUMBER, 

 "MESSAGE" VARCHAR2(30),

 "SEEN_TIME" TIMESTAMP (6), 

 "SEEN_TYPE" VARCHAR2(1)

 )

2. Put the function into the Notification page>> Function and Global Variable Declaration

(function loop(i) {

   setTimeout(function() { 

       apex.server.process ( 

          'AJAX_NOTIFICATION_CALL',

          {}, // params

          {

              async     : true,

              dataType  : 'json',

              success   : function(data) {

                 if (data.MESSAGE) {

                     if (data.SEEN_TYPE == 'N') { 

                      apex.message.showPageSuccess(data.MESSAGE);

                     }

                 }

             }

          }

       ); 

       loop(i);

   }, 4000); // 4sec forever

})();


3. Create an Ajax Call back process and put the below code into this process. Finally, Remane the process name as AJAX_NOTIFICATION_CALL.

BEGIN

       APEX_JSON.OPEN_OBJECT();

       FOR c IN (

           SELECT * FROM NOTIFICATION_TABLE WHERE SEEN_TIME IS NULL ORDER BY PID 

           FETCH FIRST 1 ROWS ONLY

       ) LOOP

           APEX_JSON.WRITE('MESSAGE', c.MESSAGE);

           APEX_JSON.WRITE('SEEN_TYPE', c.SEEN_TYPE);

           UPDATE NOTIFICATION_TABLE

           SET SEEN_TIME = LOCALTIMESTAMP,

                SEEN_TYPE = 'Y'

           WHERE PID = c.PID; 

       END LOOP;

       APEX_JSON.CLOSE_OBJECT();

    END;

4. Finally input the value into the NOTIFICATION_TABLE  table from anywhere and check the Notification page without loading. 

Restrict File Upload by File Type in Oracle Apex

If you want to restrict file upload by file type/extension/format you can follow the below steps.  Goto File Browser Item --> Advanced --...