Delete a Row of a Report with a Dynamic Action

I was asked recently how I implemented the deleting of a row in my demo application, so I thought I would post the answer here in case anyone else was curious.

To accomplish the deletion of a row with a prompt to the user for confirmation you will need a hidden page item and a dynamic action.

On the page that has your report, add a hidden page item – mine is called P20_DELETE_ID. This item will be used by our dynamic action to hold the primary key of the row on which the user clicked the delete icon.

You need to add a link column to your report for the delete icon with the following attributes:

Link Target: URL
URL: javascript:void(null);
Link Text: <span class="t-Icon fa fa-trash delete-note" aria-hidden="true"></span>
Link Attributes: data-id=#REMOVE#
Link Column

Notice in the Link Text that I added a class called delete-note. This is the jQuery selector we will use to trigger our dynamic action. Also, notice the Link Attributes – the column referenced here, in my case #REMOVE#, should hold the primary key for the row. This value will be used to identify the row that needs to be deleted in your delete PL/SQL statement.

Next, we need a dynamic action that fires on click of our jQuery selector, .delete-note. This action will have four true actions:
Delete Row Dynamic Action

True Action #1: Confirm
Text: Are you sure?
Confirm

True Action #2: Set Value
Settings:
Set Type: JavaScript Expression
JavaScript Expression: $(this.triggeringElement).parent().data('id')
Affected elements:
Selection Type: Item(s)
Items(s): P20_DELETE_ID <—- your hidden page item
Set Value

True Action #3: Execute PL/SQL Code
PL/SQL Code: delete from jsd_notes where id = :P20_DELETE_ID;
Items to Submit: P20_DELETE_ID <—- your hidden page item
Execute PL/SQL Code

True Action #4: Refresh
Selection Type: Region
Region: Notifications <—- your report region
Refresh

And that should do it 🙂
– Jackie –

Soruce from

Advertisements

How to show and hide inline dialog in oracle apex using JavaScript

How to show and hide inline dialog in oracle apex using JavaScript

  1. Create a Region named as example “Employee Details:
  2. Assign a Static ID of the region “EMPDTLS”  ( ..Region Property/Advanced/Static ID:)
  3. Create a Page Button Named “ShowDialog”
  4. Go to the button property and set it’s properties as below:
  5. Behavior/Action = Redirect to URL
  6. Target = javascript:openModal('EMPDTLS');
  7. Now Save and run the page. when you click “ShowModal” button the modal dialog will be appeared.
  8. Now for closing the Modal dialog, you can add a new button “closeDialog” in the dialog region and set the properties as below:
  9. Behavior/Action = Redirect to URL
  10. Target = javascript:closeModal(‘EMPDTLS’);
  11. If you want to pass value in the Dialog region then

    javascript:$s(‘P1_EMPID’,7369);openModal(‘EMPDTLS’);
    or

    javascript:$s(‘P1_EMPID’,$v(‘P1_EMPNO’));openModal(‘EMPDTLS’);
    or

    javascript:$s(‘P1_EMPID’,’#EMPNO#’);openModal(‘EMPDTLS’);
    or

#EMPNO# – this is applicable when you calling dialog window from Interactive or classic report. here EMPNO is the column name.

 

Source

How To Convert Number into Words using Oracle SQL Query

How can you convert a number into words using Oracle Sql Query? What I mean by Number to Word is:

12 = Twelve
102 = One Hundred Two
1020 = One Thousand Twenty

Here’s a classy query which will convert number into words.Please see the query below:

select to_char(to_date(:number,'j'),'jsp') from dual;

If I pass 234 in number, then the output will : two hundred thirty-four

SELECT TO_CHAR (TO_DATE (234, 'j'), 'jsp') FROM DUAL;
//Output: two hundred thirty-four

SELECT TO_CHAR (TO_DATE (24834, 'j'), 'jsp') FROM DUAL;
//Output: twenty-four thousand eight hundred thirty-four

SELECT TO_CHAR (TO_DATE (2447834, 'j'), 'jsp') FROM DUAL;
//Output: two million four hundred forty-seven thousand eight hundred thirty-four

So how the query works? Well here’s why:

If you look into the inner most part of the query to_date(:number,'j') the ‘j’ or J is the Julian Date (January 1, 4713 BC), basically this date is been used for astronomical studies.

So to_date(:number,'j') it take the number represented by number and pretend it is a julian date, convert into a date.

If you pass 3 to number, so it will convert date to 3rd Jan 4713 BC, it means 3 is added to the Julian date.

Now to_char(to_date(:number,'j'),'jsp')jsp = Now; take that date(to_date(:number,'j')) and spell the julian number it represents

Limitation & workaround

There is a limitation while using Julian dates ,It ranges from 1 to 5373484. That’s why if you put the values after 5373484, it will throw you an error as shown below:

ORA-01854: julian date must be between 1 and 5373484

To cater the above problem ,create a function,

and with little trick with j->jsp ,you can fetch the desired result.

create or replace FUNCTION spell_number (p_number IN NUMBER)
   RETURN VARCHAR2
AS
   TYPE myArray IS TABLE OF VARCHAR2 (255);

   l_str myArray
         := myArray ('',
                     ' thousand ',
                     ' million ',
                     ' billion ',
                     ' trillion ',
                     ' quadrillion ',
                     ' quintillion ',
                     ' sextillion ',
                     ' septillion ',
                     ' octillion ',
                     ' nonillion ',
                     ' decillion ',
                     ' undecillion ',
                     ' duodecillion ');

   l_num      VARCHAR2 (50) DEFAULT TRUNC (p_number);
   l_return   VARCHAR2 (4000);
   l_pisa     varchar2(50);
BEGIN
   FOR i IN 1 .. l_str.COUNT
   LOOP
      EXIT WHEN l_num IS NULL;

      IF (SUBSTR (l_num, LENGTH (l_num) - 2, 3) <> 0)
      THEN
         l_return :=
            TO_CHAR (TO_DATE (SUBSTR (l_num, LENGTH (l_num) - 2, 3), 'J'),
                     'Jsp')
            || l_str (i)
            || l_return;
      END IF;

      l_num := SUBSTR (l_num, 1, LENGTH (l_num) - 3);
   END LOOP;

    l_pisa := substr(p_number,instr(p_number,'.')+1,length(p_number)-instr(p_number,'.'));
    if instr(p_number,'.') > 0 and l_pisa < 99  then
    l_return := upper(l_return||' and '|| to_char(to_date(l_pisa, 'J'), 'JSP') ||' Paise Only');
    end if;
   RETURN l_return;
END;
/

SELECT spell_number (53734555555585.13) FROM DUAL;

Output:

FIFTY-THREE TRILLION SEVEN HUNDRED THIRTY-FOUR BILLION FIVE HUNDRED FIFTY-FIVE MILLION FIVE HUNDRED FIFTY-FIVE THOUSAND FIVE HUNDRED EIGHTY-FIVE AND THIRTEEN PISA ONLY

Apex – Interactive Report – Hide Column in CSV Download?

You can hide it by putting a condition on the column of type PL/SQL Expression and using the following as the expression:

NVL(:REQUEST,’MY_REQ’) IN(‘CSV’,’XLS’,’PDF’,’XML’,’RTF’,’HTMLD’)

That will check the APEX bind variable “REQUEST”, and if it is CSV, XLS, PDF, XML, RTF or HTML then the column will not be shown!

More info

To stop a column from showing up for an email, you can use the following:

NVL(wwv_flow.g_widget_action, ‘MY_REQ’) != ‘SEND_EMAIL’

 

Move the entire row to next page when one or more text fields data overflows to next page

Usually, Clients needs data to be displayed neatly at server UI level though it would be an excel extract or pdf extract.

This tip is useful when report text fields data overflows to next page with wired look and feel.

Solution : 
1) Remove “Detail Over flow” option for all the text elements that are kept on detail band if  the property is already applied.
2) Select the detail band and look into the properties of it.

Chose Split Type = Prevent instead Stretch

 

Screenshot_1

Restrict Numbers only in apex 5 input type

Use the below javascript in common js file and change input type in number the input only accept the 0-9 and dot only.

$(document).ready(function() {
    $(".number_field").keydown(function (e) {
        // Allow: backspace, delete, tab, escape, enter and .
        if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
             // Allow: Ctrl+A, Command+A
            (e.keyCode === 65 && (e.ctrlKey === true || e.metaKey === true)) || 
             // Allow: home, end, left, right, down, up
            (e.keyCode >= 35 && e.keyCode <= 40)) {
                 // let it happen, don't do anything
                 return;
        }
        // Ensure that it is a number and stop the keypress
        if ((e.shiftKey || (e.keyCode  57)) && (e.keyCode  105)) {
            e.preventDefault();
        }
    });
});