You are on page 1of 5

Insertion:

We can perform insertion with the help of EO object

Step1: Create a custom table with required columns + who columns

Ex:

create table student_ins(snum varchar2(20),sname varchar2(30), last_update_date date,last_updated_by


number,last_update_login number,creation_date date,
created_by number);

Step2: Create a sample page and test it.

Step3: Add a messageComponentLayout region under main region and add two text boxes under it.

With ids snum,sname

Step3: Add a messageLayout region under messageComponentLayout region and add a submit
button under this region. (Observer Jdeveloper)

Step4: Create an EO (rtclick on project –New ADF business ComponentsEntity Object)


Select the check boxes as shown below:
Check Generate Default View Object check box to create an EO based VO. Click finish

In application navigator Double click on AM and Attach VO to AM.


Step:5: Provide mapping to the items on the page.

Select the snum item, add View Instance and View attribute properties

View Instance: StudentEOVO

View Attribute: SNum

Select the sname item, add View Instance and View attribute properties

View Instance: StudentEOVO

View Attribute: SName

Step6: Write the Code in AM(AM is responsible for DB operations) to create a record in database

DataBaseAMIMpl.java

Import statement:

import oracle.jbo.Row // similar to Record Type

import oracle.apps.fnd.framework.server.OADBTransaction; //for DB Transaction

write the below Code before main() method:

/*Code for Create Record*/


//This create() method will create a database record
public void create()
{
// No need to get handle of AM because we are already in AM. With the help of below line, we will get access
to VO
StudentEOVOImpl vo=getStudentEOVO();
if(!vo.isPreparedForExecution()) // check for VO is ready for execution
{
vo.executeQuery(); //execute the query behind VO
}
//Creating a blank row to have new record.
Row record=vo.createRow();
// For inserting blank row into EO
vo.insertRow(record);
// For intilialising the new row with values.
record.setNewRowState(Row.STATUS_INITIALIZED);
}
// user defined method to save the record
public void save()
{
//Accesing DB Transaction
OADBTransaction trx=getOADBTransaction();
// With the help of transaction object, commiting the values
trx.commit();
}

/*End of Code for Create Record*/

Step6: Set a new controller on main region to handle apply button and write the below code in
processFromRequest after super

DataBaseAMImpl am=(DataBaseAMImpl)pageContext.getApplicationModule(webBean);

am.create();

am.save();

Check in table for new records.

You might also like