Tuesday 5 November 2019

Retrieving Script Engines in Java

A script engine registers alias names with the scripting framework.
For example, the built-in Rhino scripting registers the following names with the scripting framework:
  1. js
  2. rhino
  3. JavaScript
  4. javascript
  5. ECMAScript
  6. ecmascript
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

public class GetEngineByName {
  public static void main(String[] args) {
    ScriptEngineManager manager = new ScriptEngineManager();
    /* Retrieve a ScriptEngine registered with the rhino name */
    ScriptEngine jsEngine = manager.getEngineByName("rhino");
    if (!(jsEngine == null)) {
      System.out.println(jsEngine);
    } else {
      System.out.println("\nNo supported script engine foundregistered as Rhino.");
    }
  }
}






Run JavaScript Method in Java / ADF & OAF

Run JavaScript Method in Java / ADF & OAF   

** it is not Oracle standard.
Example Code :
 try {
      ScriptEngineManager manager = new ScriptEngineManager();
      ScriptEngine engine = manager.getEngineByName("Js");
        engine.eval("function run() {alert(123);}");
        Invocable invokeEngine = (Invocable) engine;
        Runnable runner = (Runnable)invokeEngine.getInterface(Runnable.class);
        Thread t = new Thread(runner);
        t.start();
        t.join();
      }
    catch (ScriptException e)
    {
      // TODO
    }
    catch (InterruptedException e)
    {
      // TODO
    }


incase of any null pointer Exception
visit Get JavaScript Engine Name

Java Code Examples for javax.script.ScriptEngineManager.getEngineFactories()

The following are Jave code examples for showing how to use getEngineFactories() of the javax.script.ScriptEngineManager class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.



private boolean isJavaScriptAvailable() {
    if(isJSAvailableChecked) {
        return isJSAvailable;
    }
    ScriptEngineManager mgr = new ScriptEngineManager();
    List<ScriptEngineFactory> factories = mgr.getEngineFactories();
    for (ScriptEngineFactory factory: factories) {
        List<String> engNames = factory.getNames();
        for(String name: engNames) {
            if(name.equalsIgnoreCase("js") || name.equalsIgnoreCase("javascript")) { //NOI18N
                isJSAvailableChecked = true;
                isJSAvailable = true;
                return isJSAvailable;
            }
        }
    }
    isJSAvailableChecked = true;
    isJSAvailable = false;
    return isJSAvailable;
}



OAF:
Example
try { ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngineFactory[] factories = (ScriptEngineFactory[]) mgr.getEngineFactories(); for (ScriptEngineFactory factory: factories) { String[] engNames = factory.getNames(); for(String name: engNames) { System.out.println(name); } } } catch (Exception e) { }





Trace Oracle EBS user Activities

Example 01



select distinct fu.user_name User_Name,
                fr.RESPONSIBILITY_KEY Responsibility,
                ic.first_connect Connect_Start,
                ic.last_connect Connect_Stop,
                decode(ic.Function_type,
                       'JSP',
                       'OAF Form',
                       'FORM',
                       'Oracle Java Form',
                       '') Menu,
                ic.function_id
  from fnd_user fu, fnd_responsibility fr, icx_sessions ic
 where fu.user_id = ic.user_id
   AND fr.responsibility_id = ic.responsibility_id
   AND ic.disabled_flag = 'N'
   AND ic.responsibility_id is not null
   and fu.user_id = :UserID





FND tables for login details

How to find user logged in Oracle Applications and and I would like restrict some user login during weekends to oracle applications.
 How Logged to Forms
select distinct fu.user_name User_Name,fr.RESPONSIBILITY_KEY Responsibility from fnd_user fu,
fnd_responsibility fr, icx_sessions ic
where fu.user_id = ic.user_id AND
fr.responsibility_id = ic.responsibility_id AND
ic.disabled_flag=’N’ AND
ic.responsibility_id is not null AND
ic.last_connect like sysdate;

There are three primary tables which are involved in using the system profile ‘Sign-On:Audit Level’:
1) FND_LOGINS
2) FND_LOGIN_RESPONSIBILITIES
3) FND_LOGIN_RESP_FORMS

- When the profile is set to “User”, the only table that gets updated is the table FND_LOGINS and only one record per user session

- When the profile is set to “Responsibility”, both FND_LOGINS and FND_LOGIN_RESPONSIBILITIES will be updated:
a) FND_LOGINS gets only one record per user session
b) FND_LOGIN_RESPONSIBILITIES will be updated with one record for each responsibility selected during the session

- When the profile is set to “Form” all three tables are involved:
a) FND_LOGINS gets only one record per user session
b) FND_LOGIN_RESPONSIBILITIES will be updated with one record for each responsibility selected during the session
c) FND_LOGIN_RESP_FORMS will be updated with one record for each form selected during the session
In terms of performance, the data capture has negligible overhead.

Friday 1 November 2019

System Variables In Oracle Forms list

List Of System Varible That are use iN oracle Forms

System variable
SYSTEM.BLOCK_STATUS
SYSTEM.COORDINATION_OPERATION
SYSTEM.CURRENT_BLOCK
SYSTEM.CURRENT_DATETIME
SYSTEM.CURRENT_FORM
SYSTEM.CURRENT_ITEM
SYSTEM.CURRENT_VALUE
SYSTEM.CURSOR_BLOCK
SYSTEM.CURSOR_ITEM
SYSTEM.CURSOR_RECORD
SYSTEM.CURSOR_VALUE
SYSTEM.DATE_THRESHOLD*
SYSTEM.EFFECTIVE_DATE*
SYSTEM.EVENT_WINDOW
SYSTEM.FORM_STATUS
SYSTEM.LAST_FORM
SYSTEM.LAST_QUERY
SYSTEM.LAST_RECORD
SYSTEM.MASTER_BLOCK
SYSTEM.MESSAGE_LEVEL*
SYSTEM.MODE
SYSTEM.MOUSE_BUTTON_PRESSED
SYSTEM.MOUSE_BUTTON_SHIFT_STATE
SYSTEM.MOUSE_ITEM
SYSTEM.MOUSE_CANVAS
SYSTEM.MOUSE_X_POS
SYSTEM.MOUSE_Y_POS
SYSTEM.MOUSE_RECORD
SYSTEM.MOUSE_RECORD_OFFSET
SYSTEM.RECORD_STATUS
SYSTEM.RIGHT_MOUSE_TRIGGER_NODE
SYSTEM.SUPPRESS_WORKING*
SYSTEM.TAB_NEW_PAGE
SYSTEM.TAB_PREVIOUS_PAGE
SYSTEM.TRIGGER_BLOCK
SYSTEM.TRIGGER_ITEM
SYSTEM.TRIGGER_MENUOPTION
SYSTEM.TRIGGER_NODE
SYSTEM.TRIGGER_NODE_SELECTED
SYSTEM.TRIGGER_RECORD

Decode Function

DECODE
Syntax
Purpose

DECODE compares expr to each search value one by one.

If expr is equal to a search,
Then Oracle Database returns the corresponding result.

If no match is found, then
Oracle returns default. If default is omitted, then Oracle returns null.

The arguments can be any of the numeric types (NUMBER, BINARY_FLOAT, or BINARY_
DOUBLE) or character types.

The maximum number of components in the DECODE function, including expr,
Searchesresults, and default, is 255.

DECODE ( expr , search , result
,
, default
)


Test Case
Create table plch_employees (
   Id    integer primary key
, name varchar2 (40)
, gender char (1)       
)
/
Insert into plch_employees values (100, 'Mr. John Doe','M')
/
Insert into plch_employees values (200, 'Mrs. Jane Doe','F')
/
Insert into plch_employees values (300, 'Ms. Julie Doe','F')
/
Insert into plch_employees values (400, 'Mr. Jack Doe','M')
/
Insert into plch_employees values (500, 'Dr. James Doe','M')
/
Insert into plch_employees values (600, 'Jonathan Doe','M')
/
Insert into plch_employees values (700, 'Jeff Jr. Doe','M')
/
Commit
/


select idnamedecode(gender, 'M''MALE''F''FEMALE', gender)
  from plch_employees;

Test Case:
/*
User have requirement ( if parameter value is 100 then query only show the result of those employee who have id no 100
Else query will show all employees
Expect 100 no ID)
*/
---we can handle it from our decode function 
Select idnameand decode (gender, ‘M’, MALE, ‘F’, ‘FEMALE’, gender)
  From plch_employees
  Where decode (id, 100,'Y','F') =decode (:v_id, 100,'Y','F');

ABS function in SQL

Case Study:

Get only positive Values



Practice Table:

create table plch_employees (
   id    integer primary key
, name  varchar2(40)
, gender char(1)         
)
/
insert into plch_employees values (-100, 'Mr. John Doe','M')
/
insert into plch_employees values (-200, 'Mrs. Jane Doe','F')
/
insert into plch_employees values (300, 'Ms. Julie Doe','F')
/
insert into plch_employees values (-400, 'Mr. Jack Doe','M')
/
insert into plch_employees values (500, 'Dr. James Doe','M')
/
insert into plch_employees values (600, 'Jonathan Doe','M')
/
insert into plch_employees values (700, 'Jeff Jr. Doe','M')
/
commit
/



ABS
Syntax
Purpose

The ABS function returns the absolute value of a number, which will always be zero or a positive number.
This function takes as an argument any numeric data type or any nonnumeric data
type that can be implicitly converted to a numeric data type.

Examples


The following example returns the absolute value of -15:

SELECT ABS (-15) "Absolute"
FROM DUAL;
Absolute
----------
15

OADBTransactionImpl in Oracle Application Framework (OAF)

OADBTransactionImpl is a class in Oracle Application Framework (OAF), which is a framework for building Oracle E-Business Suite applications...