Wednesday, February 27, 2013

Using insertRow Vs insertRowAtRangeIndex

Using insertRow Vs insertRowAtRangeIndex

Scenario 1

    OAViewObjectImpl pervo = getDataVO1();
    if(!pervo.isPreparedForExecution())
         pervo.executeQuery();
     Row prow = pervo.createRow();
     prow.setAttribute("field",fieldvalue);
     pervo.insertRowAtRangeIndex(0,prow);
     prow.setNewRowState(Row.STATUS_INITIALIZED);

Scenario 2
    OAViewObjectImpl pervo = getDataVO1();
    if(!pervo.isPreparedForExecution())
         pervo.executeQuery();
     Row prow = pervo.createRow();
     prow.setAttribute("field",fieldvalue);
     pervo.last();
     pervo.next();
     pervo.insertRow(prow);
     prow.setNewRowState(Row.STATUS_INITIALIZED);


If you use the first method, it will add a row to the first record of the current page. Whereas if you use the second method it will add to last record of the last page

if you use pervo.insertRowAtRangeIndex(pervo.getRowCount-1,prow); it will work when there is 1 page only, if it goes to second page it will throw error

Monday, February 25, 2013

Get Profile settings user level from Database

Query to retrieve profile seetings which are customized for user

select user_profile_option_name,
       decode(level_id,
              10001,
              'Site',
              10002,
              'Application',
              10003,
              'Responsibility',
              10004,
              'User',
              10005,
              'Server',
              'UnDef'),
       usr.user_Name,
       optval.*
  from fnd_profile_option_values optval
  join FND_PROFILE_OPTIONS_VL opt
    on opt.profile_option_id = optval.PROFILE_OPTION_ID
  join FND_USER usr
    on optval.level_value = usr.user_id
 where level_id = 10004
  

Difference Between getAllRowsInRange and getRowAtRangeIndex

We can retrieve the rows of an VO by 2 methods

Example 1
   oracle.jbo.Row rows[] = getdataVo.getAllRowsInRange();
 for (int i = 0; i < rows.Lengthi++)
{
   GetDataVORowImpl cafConfigVORow = (GetDataVORowImpl)rows(i);
}

Example 2
for (int i = 0; i < getDataVo.getRowCount(); i++)
{
    GetDataVORowImpl cafConfigVORow = (GetDataVORowImpl)getDataVo.getRowAtRangeIndex(i);
}


The difference betwen both is the first one will get records of first page only whereas the second example will retrieve all records.