Thursday, September 19, 2019

the table cannot be sorted because it has pending changes which would be lost

Hello friends,

If you ever face the above issue or similar issue like The search cannot be executed because the table has pending changes that would be lost.      

Open your VOROwimpl.java file. search for the transient attribute in the vo.

Eg. if your transient attribute is RforceAccountId then search for setRforceAccountId method and comment the setattribuetinternal method and put populateattribute method instead of that. see the screen shot below:


                  

After changing this deploy the latest rowimpl.java to server and compile it and bounce the apache.

Your issue will be resolved.
 

Wednesday, May 29, 2019

500 Internal Server Error

500 Internal Server Error

oracle.apps.fnd.common.AppsException: oracle.apps.fnd.common.PoolException: Exception creating new Poolable object.

If you are getting the above error while running the page from Jdeveloper that means you have opened so many sessions and not logged out them.

For this you will have to ask DBA to kill the sessions.

Once you start running page from JDeveloper, every time log out instead of directly closing the window.

if it does not solve the issue then run below query in sql developer.

SELECT node_id,
 platform_code,
 support_db D,
 support_cp C,
 support_admin A,
 support_forms F,
 support_web W,
 node_name,
 server_id,
 server_address,
 domain,
 webhost,
 virtual_ip,
 status
FROM fnd_nodes
ORDER BY node_id;

take server_id value from the above query and put in the DBC file parameters against APPL_SERVER_ID and save the DBC file and retest the issue.

Friday, May 3, 2019

How to find out nth highest salary of an employee




SELECT Salary, id
FROM
(
SELECT Salary,id,DENSE_RANK() OVER(ORDER BY Salary ASC) Row_numbr from emp1
) tbl
WHERE Row_numbr=n

In the above example if you want to find out the 3rd higest salary of an employee, then pass 3 in place of n.

Wednesday, April 24, 2019

PL SQL COMPOSITE DATA TYPE

DATA TYPE :

 1) Scalar Data Type :

a) Number
b) Date
c) Varchar2
d) blob
e) clob

2) Composite data Type :

1) PL/SQL Records :

SET SERVEROUTPUT ON;
DECLARE
    TYPE emprectype IS RECORD ( name     VARCHAR2(50),
    hire_date      date,
    dob      DATE ,
    emp_no   number);
    emprec emprectype;
BEGIN
  select first_name || last_name , hire_date,dob,emp_no
  into emprec
  from emp
  where emp_no=100;
    dbms_output.put_line('Employee Name ' || emprec.name || ' has hire dat as  ' || emprec.hire_date  || ' and date of birth is ' || emprec.dob);
END;

insert data into table using records


SET SERVEROUTPUT ON;
DECLARE
    dept_rec   dept%rowtype;
BEGIN
    dept_rec.deptno := 90;
    dept_rec.dname := 'FINANCE';
    INSERT INTO dept VALUES dept_rec;
    COMMIT;
END;
update data into table using records
SET SERVEROUTPUT ON;
DECLARE
    dept_rec   dept%rowtype;
BEGIN
    dept_rec.deptno := 90;
    dept_rec.dname := 'FIN-updated';
    dept_rec.loc := 'USA';
  update dept set row = dept_rec where  deptno=90;
    COMMIT;
END;

2) COLLECTIONS:

a) PL/SQL Table :

Already covered in previous posts

b) VArray :

example 1:
SET SERVEROUTPUT ON;
DECLARE
    TYPE varry_typ IS
        VARRAY ( 10 ) OF NUMBER;
    varr   varry_typ;
BEGIN
    varr := varry_typ ();
    varr.extend ();
    varr(1) := 85;
    varr.extend ();
    varr(2) := 88;
    dbms_output.put_line('varr 1 value is '
                           || varr(1)
                           || ' varr 2 value is '
                           || varr(2) );
END;

Example 2:
SET SERVEROUTPUT ON;
DECLARE
    TYPE varry_typ IS
        VARRAY ( 10 ) OF NUMBER;
    varr   varry_typ;
BEGIN
    varr := varry_typ (11,22,33,44,55,66,77);
    dbms_output.put_line('varr 1 value is '
                           || varr(1)
                           || ' varr 2 value is '
                           || varr(2) );
END;


Example 3:
varr.Exists(5) means it will written true if 5th element in the array exists. if not exist then will written value as false.
varr.first will return you first element sequence not value and varr.last will written the last available sequence  not value in varray.
varr.PRIOR(2) will give the value in the 1st element value.
varr.NEXT(2) will give the value of 3rd element
varr.EXTEND() will allocate the memory so that we can assign value tot he element further. without this we can't assign the value to any element of varray. If we want to assign the value to two elements then we have to write this twice.
varr.trim(1)  will delete the last available value from the varray.
varr.trim(2)  will delete the last two available values from the varray.
varr.count  will give you only those values which are not deleted yet. if its trimmed then it won't count those values further.
SET SERVEROUTPUT ON;
DECLARE
    TYPE varry_typ IS VARRAY ( 10 ) OF NUMBER;
    vemp   varry_typ := varry_typ(11,22,33,44,55,66,77);
BEGIN
dbms_output.put_line('vemp count ' || vemp.count);
dbms_output.put_line('vemp limit ' || vemp.limit);
dbms_output.put_line('vemp first ' || vemp.first);
dbms_output.put_line('vemp last ' || vemp.last);
vemp.trim(2);
dbms_output.put_line('after vemp count ' || vemp.count);
dbms_output.put_line('after vemp limit ' || vemp.limit);
dbms_output.put_line('after vemp first ' || vemp.first);
dbms_output.put_line('after vemp last ' || vemp.last);
dbms_output.put_line('vemp 1 ' || vemp(1));
END;

c) Nested tables:

only difference between nested table and varray is the size. in varray size is limited whereas in nested table size is not fixed at the time of design. Also nested tabke is not dense as we can delete any element even from the middle as well. There is no limit function in this as its unbounded.

SET SERVEROUTPUT ON;
DECLARE
--TYPE varry_typ is varray(10) of number;
    TYPE varry_typ IS table OF NUMBER;
    vemp   varry_typ ;
    cursor c1 is
    select emp_no from emp;
    counter number :=1;
BEGIN
vemp :=varry_typ();
for i in c1 loop
vemp.extend();
vemp(counter) := i.emp_no;
dbms_output.put_line( 'vemp(' || counter || ') ' || vemp(counter) );
counter := counter + 1;
end loop;
END;

d) index by tables: associative array;

it has both the feature of nested table and as well as varray too. Only good thing is that in this it s defined by key and value structure means key should always be unique and not null.There is no limit function in this as its unbounded.
SET SERVEROUTPUT ON;
DECLARE
    TYPE l_empnotab IS TABLE OF number INDEX BY PLS_INTEGER;
    l_emparr   l_empnotab;
BEGIN
l_emparr(1) := 56;
l_emparr(3) :=78;
END;
in the above example 1 and 3 are key and 78 and 56 are values.No need to allocate memory in this table.
l_emparr.exists(n) return the true if any key is matching with value on n.
l_emparr.first will return you the smallest key value.
l_emparr.prior(3) will return as 1 because 1 is the key which is below 3 value.
 l_emparr.delete(7,10) means delete the elements from 7 to 10 means delete 7,8,9,10.
Below example to use rowtype in pl/sql table type:
SET SERVEROUTPUT ON;
DECLARE
    TYPE l_empnotab IS
        TABLE OF emp%rowtype INDEX BY PLS_INTEGER;
    l_emparr   l_empnotab;
    i          NUMBER :=1;
    y          emp%rowtype;
BEGIN
    SELECT * BULK COLLECT
    INTO l_emparr
    FROM emp;
    LOOP
        dbms_output.put_line('employee number:' || l_emparr(i).emp_no);
        i := l_emparr.next(i);
        EXIT WHEN i IS NULL;
    END LOOP;
END;

Tuesday, April 23, 2019

BULK COLLECT AND BULK BINDING



Basic example of BULK COLLECT


SET SERVEROUTPUT ON; DECLARE
    TYPE l_emplnotab IS
        TABLE OF per_all_people_f.employee_number%TYPE;
    TYPE l_emplnametab IS
        TABLE OF per_all_people_f.full_name%TYPE;
    l_empnoarr     l_emplnotab;
    l_empnamearr   l_emplnametab;
    CURSOR c1 IS SELECT
                     employee_number,
                     full_name
                 FROM
                     per_all_people_f
                 WHERE
                     ROWNUM <= 10;
BEGIN OPEN c1; LOOP
    FETCH c1 BULK COLLECT INTO
        l_empnoarr,
        l_empnamearr;
    CLOSE c1;
    FOR i IN l_empnoarr.first..l_empnoarr.last LOOP
        dbms_output.put_line('employee number: '
                               || l_empnoarr(i)
                               || ' and employee name is :'
                               || l_empnamearr(i) );
    END LOOP;
    end;


Output of the above block:

 
employee number: 158204 and employee name is :Baumann, Albert J
employee number: 197145 and employee name is :Stanton, Dennis R.
employee number: 197942 and employee name is :Walker, Heseelyah Malina (Malina)
employee number: 198606 and employee name is :Adiga, Suresh
employee number:  and employee name is :Srinivasan, S.
employee number: 198615 and employee name is :Uppin, Vijay
employee number: 198613 and employee name is :Corcoran, Daniel
employee number: 160379 and employee name is :Stebbeds, Tracy D.
employee number: 188314 and employee name is :Marcial, Lisa Betty
employee number: 189610 and employee name is :Phillips, Dawn Nichole

 

BULK BIND EXAMPLE:

 
SET SERVEROUTPUT ON;
DECLARE
    TYPE l_empnotab IS
        TABLE OF test1.a%TYPE INDEX BY PLS_INTEGER;
    l_emparr   l_empnotab;
    l_size     NUMBER;
    k          NUMBER;
BEGIN
    l_size := 1000;
    FOR j IN 1..1000 LOOP
        l_emparr(j) := j;
    END LOOP;
--execute IMMEDIATE 'truncate table test1';
    FORALL i IN l_emparr.first..l_emparr.last
        INSERT INTO test1 VALUES ( l_emparr(i) );
    COMMIT;
END;

 

How to Create Ref Cursor and sys_refcursor in PL/SQL


Below basic example is to create a ref cursor to print employee name with email address for first 5 rows.

Ref cursor example


set serveroutput on;
declare
type emp_refcursortype is ref cursor;
emp_cursor emp_refcursortype;
emp_rec     per_all_people_f%rowtype;
query_stmt varchar2(300) := 'select * from per_all_people_f ';
v_gender varchar2(5):='F';
begin
if v_gender is null then
query_stmt := query_stmt || ' where rownum<=5';
open emp_cursor for query_stmt;
else
query_stmt := query_stmt || ' where sex = :v_gender and rownum<=5';
open emp_cursor for query_stmt using v_gender;
end if;
loop
fetch emp_cursor into emp_rec;
exit when emp_cursor%notfound;
dbms_output.put_line('Employee_name '|| emp_rec.full_name || ' with email address ' ||  emp_rec.email_address || ' with gender ' || emp_rec.sex);
end loop;
close emp_cursor;
end;

SYS_REFCURSOR DECLARATION

emp_cursor       SYS_Refcursor ; 

Tuesday, April 2, 2019

How to use iterator to process multiple rows of table in OA framework





Today I will show you how to use iterator for table rows to perform any validation.

For example you have to validate table rows for any duplicate item, and throw an error If any.

Below code will be written in AM
        

      public String DuplicateRecords(String eid,Object invItemId)
     {
        
         RowSetIterator iter = getXX_InclusiveSuppliesVO1().createRowSetIterator("iter");
         int i=1;
         String returnString = "N";
         while(iter.hasNext()) {
         Row currRow = iter.next();
getOADBTransaction().writeDiagnostics(this,"inside
DuplicateRecords:"+i,1);
         i=i+1;
             String currEid = (String)currRow.getAttribute("Eid");
             Object itemIdObject = currRow.getAttribute("UniqueValue");
          //   String currInvItemId = (String)itemIdObject;
             String itemNumber = (String)currRow.getAttribute("Item");
             getOADBTransaction().writeDiagnostics(this," currEid:"+currEid+" itemIdObject:"+itemIdObject,1);
            if (!(("").equals(currEid) ) && !(("").equals(itemIdObject) ))
            {
                if(currEid.equals(eid) && invItemId.equals(itemIdObject))
                {
                    returnString = "The combination of same EID:"+eid+" and ITEM:"+itemNumber+" already available in Inclusive table";
                    break;
                }
               
             }
         }
         iter.closeRowSetIterator();
         return returnString;
     }