Search This Blog

Tuesday, August 7, 2018

Global Back Button in Oracle Apex Using JavaScript


Back Button in Oracle Apex by doing this you can go back your immediate previous page.

1. Create a button with name "Back"

2. Button Properties >> Action When Button Clicked >>Action>> Redirect to URL >> URL Target>>    javascript:history.go(-1) 

And Enjoy 

Call Process From Dynamic Action in Oracle Apex 5.1




Some time we have need long PL/SQL block or raise_applicaiton_error and many other things which we can do in Apex Process level but can not do in Dynamic Action.

Now here I am show how to call a Process from item  Dynamic Action.

1. Create a Item and create Dynamic Action on this Item. 

2. This Dynamic Action Event can be anything but Action will Execute JavaScript Code and right this JavaScript Code >> Settings.

apex.submit({  request:"ID", showWait:true});

3.  Here "ID" is a reference to call a process. 

4.  Now a Create One or multiple Process with what ever as your wish.

5.  Go to Process >>Properties >> Conditions>> Condition Type >>Select :- Request= Expression 1 >> Expression 1 >> ID (reference)

That's It. Now enjoy Process form Dynamic Action.

Make a Oracle Apex 5.1 Item Readonly

Make a Oracle Apex 5.1 Item Readonly. It's not mean Display Only item type. By doing this you can just read a input text field but can not edit or remove.

1. Make a Item in a Region.

2. Go to Item properties >> Element >>HTML Form Element Attributes >> readonly

and Save.   

RESTful Get API Example in Oracle Apex

DECLARE
   l_param_list      VARCHAR2 (512);
   l_http_request    UTL_HTTP.req;
   l_http_response   UTL_HTTP.resp;
   l_response_text   VARCHAR2 (32767);
   l_response        VARCHAR2 (32767);

   v_url             VARCHAR (500);
   url_param_list    VARCHAR2 (512);

   p_userid          VARCHAR2 (500) := '100140';
   p_sessionid       VARCHAR2 (500) := '123456';
   p_companyid       VARCHAR2 (500) := '101';
   p_executionmode   VARCHAR2 (500) := 'S';
   p_studentid       VARCHAR2 (500) := '9005';
   p_authkey         VARCHAR2 (500) := 123456;
   ts                VARCHAR2 (32000)
      := '{"std_info_node":[{"errormessage":"Invalid ID . Please input valid ID","studentname":"Qaium","accountno":"0487878778","mobileno":"01234","errorcode":"1"}]}';

   l_data_count      NUMBER := 0;
   l_values          apex_json.t_values;

   t_timeout         INTEGER;
BEGIN
   v_url := 'http://10.11.150.12/PmsWebService/StudentInfo?';
   url_param_list :=
         'userid='
      || p_userid
      || '&sessionid='
      || p_sessionid
      || '&companyid='
      || p_companyid
      || '&executionmode='
      || p_executionmode
      || '&studentid='
      || :P180_STUDENT_ID                                        
      || '&authkey='
      || p_authkey;

   /*begin
   l_http_request :=  UTL_HTTP.begin_request (v_url, 'GET', 'HTTP/1.1');
   UTL_HTTP.write_text (l_http_request, l_param_list);
   --  raise_application_error(-20007,'1');
   l_http_response := UTL_HTTP.get_response (l_http_request);
   raise_application_error(-20007,'2 : '||l_http_response.status_code);
   end ; */

   UTL_HTTP.get_transfer_timeout (t_timeout);
   UTL_HTTP.set_transfer_timeout (10);
   UTL_HTTP.get_transfer_timeout (t_timeout);

   l_param_list := NULL;
   l_http_request :=
      UTL_HTTP.begin_request (v_url || url_param_list, 'GET', 'HTTP/1.1');
   UTL_HTTP.write_text (l_http_request, l_param_list);
   l_http_response := UTL_HTTP.get_response (l_http_request);

   UTL_HTTP.read_text (l_http_response, l_response_text);

   IF l_response_text IS NULL
   THEN
      raise_application_error (-20003,
                               'Request Does Not Get Any Response !!!');
   END IF;

   apex_json.parse (l_response_text);

   SELECT    'DCMC'
          || REPLACE (TO_CHAR (SYSDATE, 'DD-MM-YY'), '-', '')
          || DCMC_PAYMENT.NEXTVAL
     INTO :P180_REF_NO
     FROM DUAL;

   :P180_NAME :=
      apex_json.get_varchar2 (p_path => 'std_info_node[1].studentname');
   :P180_MOBILE :=
      apex_json.get_varchar2 (p_path => 'std_info_node[1].mobileno');
   :P180_AC_NUMBER :=
      apex_json.get_varchar2 (p_path => 'std_info_node[1].accountno');
   --raise_application_error(-20003,:P180_MOBILE);

   /*
    FOR i IN 1 ..3

    LOOP
   :P180_NAME:= apex_json.get_varchar2 (p_path => 'std_info_node[' || i || '].studentname') ;
   :P180_MOBILE:= apex_json.get_varchar2 (p_path => 'std_info_node[' || i || '].mobileno') ;
   :P180_AC_NUMBER :=apex_json.get_varchar2 (p_path => 'std_info_node[' || i || '].accountno') ;

    -- DBMS_OUTPUT.put_line ('a is '|| apex_json.get_varchar2 (p_path => 'std_info_node[' || i || '].studentname')|| l_data_count);

    END LOOP; */

   UTL_HTTP.end_response (l_http_response);
EXCEPTION
   WHEN UTL_HTTP.end_of_body
   THEN
      UTL_HTTP.end_response (l_http_response);
END;

Monday, July 16, 2018

PL/SQL To JSON Conversion





SET SERVEROUTPUT ON
DECLARE
  l_cursor SYS_REFCURSOR;
BEGIN
  
  OPEN l_cursor FOR
    SELECT e.empno AS "employee_number",
           e.ename AS "employee_name",
           e.deptno AS "department_number"
    FROM   emp e ;
   -- WHERE  rownum <= 2;

  APEX_JSON.initialize_clob_output;

  APEX_JSON.open_object;
  APEX_JSON.write('employees', l_cursor);
  APEX_JSON.close_object;

  DBMS_OUTPUT.put_line(APEX_JSON.get_clob_output);
  APEX_JSON.free_output;
END;

OUTPUT WILL LIKE :

{"employees":[{"employee_number":4,"employee_name":"ZAMAN","department_number":30}
,{"employee_number":2,"employee_name":"ZAMAN","department_number":30}
,{"employee_number":3,"employee_name":"ZAMAN","department_number":30}
,{"employee_number":1,"employee_name":"ZAMAN","department_number":30}
,{"employee_number":6,"employee_name":"ZAMAN","department_number":30}
,{"employee_number":7,"employee_name":"aa","department_number":30}
,{"employee_number":5,"employee_name":"jhjkhkj"}]}


Thursday, July 5, 2018

Classic Report Scroll Bar in Oracle Apex

To add scroll bar on classic report .

Use this CSS on Region >> Region Attribute

<div style ="overflow-x: scroll;overflow-y: scroll;height:500px;">
<div style ="overflow:auto;height:220px;"> 

Region Print by JavaScript Clicking on Button And Save PDF in Oracle Apex


1. Create a Region and Do what ever you want.

2. Set a static id of the region. Region properties>>Advance>>Static ID >> exp: printableArea

3. Create a button and use this code. Button properties>>Advance>>Custom Attributes>> 

onclick="printDiv('printableArea')"

4. Use this code on. Region propertice>>Footer Text>>

<script>
function printDiv(printableArea) {
     var printContents = document.getElementById(printableArea).innerHTML;
     var originalContents = document.body.innerHTML;
    document.body.innerHTML = printContents;
     window.print();
     document.body.innerHTML = originalContents;
}
</script>

Now Enjoy Region Print by JavaScript clicking on print button ..

Monday, July 2, 2018

Auto New Row Generation In Interactive Grid Using Bar-code Reader or Manual Input


1. Create a page and a region type Interactive Grid form from a table.
  (using where 1=2 for showing empty grid).

2. Now create a Dynamic action with Change Event and Execute javaScript Action
on column, from where new row will create.

3. Then goto Region Properties Advanced>> Static ID >> type a id like: REG_ID

4.Use below JavaScript for create new from Upper side new row.

apex.region("REG_ID").widget().interactiveGrid("getActions").invoke("row-add-row")
OR

apex.region("REG_ID").widget().interactiveGrid("getActions").invoke("insert-record")
 (for down side new row)

(After making interactive grid if there any primary key problem then go to a primary key column>>
Sours>>Primary Key>>Yes)

Saturday, June 30, 2018

Tabular Form Empty Row Show Without Data.


1. Create a Tabular form from Page Create>>Legacy Page  using any table.
2. Here are a Auto created Add button. Go to the Add button properties>> Behavior >> Target >>      URL. There will be a JavaScript like this:        javascript:apex.widget.tabular.addRow(); 
3. Now Copy the JavaScript . Create a Page Load Event Dynamic Action with Execute JavaScript Action. Finally Pest your copied JavaScript code as much time as much empty Row you want.
Finally Save the page and Enjoy Tabular empty row. :)

(If  you can't understand anything. Please comment here or mail me)

Wednesday, May 23, 2018

Download Text File With Unlimited Character



1. Make a Region with PL/SQL Dynamic Content  type .
==========
2. Assign ID to the region using  HTP.p (<span id="TEST_ID">) and Select data from table into  a  CLOB Type Variable  and Print the variable using HTP.p
==========
Example :

HTP.p ('<a download="Subject_Info.txt" id="downloadlink"  ><b>Download</b></a> <br> <br> <br>');  

DECLARE
  
   v_text     CLOB;
BEGIN
HTP.p ('<span id="TEST_ID">');      
      FOR i
         IN (SELECT    EMPLOYEE_ID  -- Select data from table
                 || FIRST_NAME
                 || LAST_NAME
                 || JOB
                 || HIRE_DATE
                 || SALARY
                 || DEPARTMENT_ID
                    AS Alias
            FROM EMPLOYEES )
      LOOP
  v_text := i."Alias";
         
      /*   HTP.p ('' || replace(v_text,'&amp;','&') || '');*/
     HTP.p (''|| replace (replace (UPPER(v_text), chr (13), ''), chr (10), ' ')|| '');
       
      END LOOP;

      HTP.p ('</span>');

END;



3.Copy Pest the JavaScript code into Page >> Function and Global Variable Declaration
==========

(function () {
    var textFile = null,
    makeTextFile = function (text) {
    var data = new Blob([text], {type: 'text/plain'});
    if (textFile !== null) {
    window.URL.revokeObjectURL(textFile);}
    textFile = window.URL.createObjectURL(data);
    return textFile;};
    var create = document.getElementById('create'),
    textbox = document.getElementById('TEST_ID'); 

    var link = document.getElementById('downloadlink');
    link.href =          makeTextFile(textbox.innerHTML.replace(/&amp;/g,"&").trim());
    link.style.display = 'block';

})();




Click On Download




Create a Form Using Python for Save Data into Excel like a Database

#Download Pyhton from here https://www.python.org/downloads/  #Download Python: #Click the “Download Python 3.x.x” button (the latest versio...