Bulk Updating Interactive Grid Records

March 23, 2017 at 9:36 am | Posted in Oracle Developement | 2 Comments

After my previous post on Updating Interactive Grid Cells, I wanted to try bulk updating IG records.

In this example I want to bulk update the salaries and commissions for the employees. I created a new button called Double Salaries. When the button is clicked, the salaries of the selected employees get doubled. The employees with no salary get a salary of 1000. Sales people will get their commission updated to 10% of their new salary.

Employees are selected by clicking the row selector checkbox of the interactive grid. The interactive grid’s static ID is emps.

The work is done by the JavaScript action of a dynamic action on the Double Salaries button:

var record, sal;
//Identify the particular interactive grid
var ig$     = apex.region("emps").widget();

//Fetch the model for the interactive grid
var grid    = ig$.interactiveGrid("getViews","grid");

//Fetch the model for the interactive grid
var model   = ig$.interactiveGrid("getViews","grid").model;

//Fetch selected records
var selectedRecords = apex.region("emps").widget().interactiveGrid("getViews","grid").view$.grid("getSelectedRecords");

//Loop through selected records and update value of the salary column
for (idx=0; idx < selectedRecords.length; idx++) {
    //Get the record
    record = model.getRecord(selectedRecords[idx][0]);

    //Get the current salary and commision values
    sal  = model.getValue(record,"SAL");
    job  = model.getValue(record,"JOB");
    comm = model.getValue(record,"COMM");

    //If there is no salary, set it to 1000, else double it
    if (sal === '') {
        sal = 1000;
    } else {
        sal = sal * 2;
    }

    //Update the record with doubled salary and new commission
    model.setValue(record,"SAL", sal);


    //Set commission to 10% of salary for sales people
    if (job = 'SALESMAN') {
        comm = sal *.1;
        model.setValue(record,"COMM", comm);
    }

}

emps_bulk

Node Newbie Error – NPM Refusing to Install Package as a Dependency of Itself

March 22, 2017 at 10:36 am | Posted in Oracle Developement | Leave a comment

Source: Node Newbie Error – NPM Refusing to Install Package as a Dependency of Itself

APEX: Updating Interactive Grid Cells

March 9, 2017 at 5:34 pm | Posted in Oracle Developement | 4 Comments

Moving from the old tabular form to the interactive grid takes some getting used to. Especially when trying to manually update cells with JavaScript.

Here is an example of how to access and modify particular cells in an interactive grid with JavaScript. The example promotes an employee when the Promote link is clicked, which doubles the employee’s salary, and assigns him a new job.

First I built an interactive grid on the EMP table. I’ve used all the defaults except:
Enable editing with Update Row.
Set the region’s static ID to emps.
Added a link column with target type: URL, URL: #

ir-link

The link text is set to Promote, and I added class (ig-link) so that I can connect a dynamic action to it:

ig-link2

Next I created a dynamic action that fires when the Promote link is clicked.

ig-da1

The true action is a Execute JavaScript Code action, with the following code:

//Get the link element that was clicked
var $te = $(this.triggeringElement);

//Get the ID of the row
var rowId = $te.closest('tr').data('id');

//Identify the particular interactive grid
var ig$ = apex.region("emps").widget();

//Fetch the model for the interactive grid
var model = ig$.interactiveGrid("getViews","grid").model;

//Fetch the record for the particular rowId
var record = model.getRecord(rowId);

//Access the cell value via the column name
var sal = model.getValue(record,"SAL");

//Set the values for the JOB and SAL cells
model.setValue(record,"JOB",'MANAGER');
model.setValue(record,"SAL",sal*2);

Here is the working example:

emps

It is worth noting that the <tr> element of the interactive grid row contains the row’s unique identifier. This could be a row ID or a primary key value, depending on how you configured the grid.

 

Tuning Tomcat for APEX/ORDS in Production

January 16, 2017 at 10:44 am | Posted in Oracle Developement | Leave a comment

Excellent blog post by Johnathan Dixon about configuring Tomcat for use with ORDS.

http://www.cloudnueva.com/blog/tuning-tomcat-for-apexords-in-production

 

Creating ORDS REST Services with PL/SQL

December 30, 2016 at 11:31 am | Posted in Oracle Developement | Leave a comment

Here is an excellent writeup for creating REST services with PL/SQL:

https://oracle-base.com/articles/misc/oracle-rest-data-services-ords-create-basic-rest-web-services-using-plsql

 

SQL*Plus Error OID generation failed

November 21, 2016 at 9:40 am | Posted in Oracle Developement | Leave a comment

I received this error on a MacBook, when trying to connect with SQL*Plus to my database:

SQL*Plus: Release 12.1.0.2.0 Production on Mon Nov 21 08:27:22 2016

Copyright (c) 1982, 2016, Oracle. All rights reserved.

ERROR:
ORA-21561: OID generation failed

The issue comes from not having the MacBook’s hostname associated with the home IP address. To fix this, simply find your hostname:

~$ hostname
MY_MACBOOK

Then edit your /etc/hosts file and add the home name to the home IP address:

127.0.0.1       localhost MY_MACBOOK

Also make sure that when you edit the hosts file, that you are not connected to a VPN. Some VPN clients may overwrite the hosts file.

 

Create your own Font Awesome Icon

October 17, 2016 at 2:02 pm | Posted in Oracle Developement | Leave a comment

There may be a special character you wish to use in the same way you would use a Font Awesome icon. To do this you need to find the hex code for the character and a little bit of CSS.

  1. Find the hex code for your character
    There are many sites that show you the ASCII values for various letters, numbers, or characters. I needed to have the greek letter Sigma, (Σ) so I looked it up here, and copied the hex value 03A3.
  2. Add CSS to your page or global CSS file:
    .sigma:before {
       content: "\03a3";
    }
  3. Use the new CSS class like any other Font Awesome icon:
    <i class="fa sigma"></a>

You can also use any of the Font Awesome modifiers such as size with this method.

Please leave a comment if this helped you.

Cheers!

APEX 5 DA when cancelling modal dialog

October 11, 2016 at 11:15 am | Posted in Oracle Developement | 1 Comment

I needed to have a dynamic action that fires when a modal dialog is cancelled or the escape key is pressed. To do this in APEX 5, on the parent page, you can create a dynamic action based on a custom event called dialogclose.

Parent page:
Custom Dynamic Action

When:
Event: Custom
Custom Event: dialogclose
Selection Type: JavaScript Expression
JavaScript Expression: document

The True/False actions can be set as usual, such as refreshing a report or setting some value.

 

 

#YourBlogHelpedMe

October 11, 2016 at 10:51 am | Posted in Oracle Developement | Leave a comment

In light of the OTN Appreciation day I want to start a little initiative of appreciation myself. I know my job would be quite a bit more difficult if it weren’t for the help I receive from other people’s blogs.

Writing helpful blog posts takes time and effort. In order to show a little bit of appreciation to the bloggers who take the time and make the effort to post helpful articles, I’m going to let them know via twitter, using their handle and the hashtag #YourBlogHelpedMe.

I encourage others to do so as well. I’m sure it will not only allow us to show gratitude, but it will encourage more bloggers to write, and built up the community.

Cheers

OTN Appreciation Day: Oracle JET Cookbook

October 11, 2016 at 9:35 am | Posted in Oracle Developement | Leave a comment

I’m taking part in the Massive Open Online Course (MOOC) for learning about the Oracle Javascript Extension Toolkit (JET). I’m impressed with the quality of the learning materials and the methodology by which the course is taught. I’m especially impressed with the Oracle JET Cookbook, the site that allows you to browse, explore, and learn about the many available components available in the JET.

It is amazing how well the cookbook is laid out, and how easy it is to find component examples and code samples. There are also previews available for various mobile devices, and the JavaScript documentation intelligently linked for each example.

All in all: Well done, and thank you for providing such an awesome resource!

jet

 

« Previous PageNext Page »


Entries and comments feeds.