Thursday, 17 May 2012

delete,insert, and update at one place in AM (do not use update and delete query of sql note it)


public void deletePersonMethod( String pPersonId ){
  try{  System.out.println("inside deletePersonMethod() i have this id to delete="+pPersonId) ;
  EmprequisitionViewImpl pervo = getEmprequisitionView1();
  String existingWhereClause = pervo.getWhereClause() ;
  pervo.setWhereClauseParams(null);
   pervo.setWhereClause("Empid= :1");
   pervo.setWhereClauseParam(0, new Number(pPersonId));
  pervo.executeQuery();
   System.out.println("row loaded");
   Row row[] = pervo.getAllRowsInRange();
   EmprequisitionViewRowImpl row0 = (EmprequisitionViewRowImpl)row[0];
   row0.remove();
    System.out.println("inside deleted");
  } catch(Exception exception1)   { throw OAException.wrapperException(exception1);   }
 }//end delete function
public void OurInsertMethod( ){
System.out.println("I am insert method in OurInsertMethod"+empid+empname+empdesign+empdepart+empdiv+ emploc );
 //get a handle to the View Object that we wish to initialize
    OAViewObject vo = (OAViewObject)getEmprequisitionView1();
    if(!vo.isPreparedForExecution()){
     vo.executeQuery();
     System.out.println("I have executed the query Query");
    }
  //Create a blank Row
      Row row = vo.createRow();
     System.out.println("I have  created a blank row for the data");
    //Attach that blank row to the VO. Data will be fed into this row, when the user types into the fields
        vo.insertRow(row);
      System.out.println("Attached the blank row to the view");
    //Set the status of the blank row to initialized. This tells OA Framework that record is blank and must not be included in DML
    //Operations until    changes are made to its underlying VO [via screen fields]
    row.setNewRowState(Row.STATUS_INITIALIZED);
    }
public void updatePersonMethod( String pPersonId)  {
  try{  System.out.println(" I have"+ pPersonId);
        EmprequisitionViewImpl pervo = getEmprequisitionView1();
        String existingWhereClause = pervo.getWhereClause() ;
        pervo.setWhereClauseParams(null);
        pervo.setWhereClause("Empid= :1");
        pervo.setWhereClauseParam(0, new Number(pPersonId));
        pervo.executeQuery();
        pervo.setWhereClauseParams(null);
        pervo.setWhereClause(existingWhereClause);
   }
   catch(Exception exception1) { throw OAException.wrapperException(exception1);   }
  }

No comments:

Post a Comment