Sunday, March 21, 2010

Inserting Data in hidden detailed table after inserting in Master one

When working with a friend trying to insert data in a detailed table (without dropping the detailed table in a page view associated with its master table), and getting some of the detailed table column values from the same data inserted in the master table, we came across to use the following code:

public String insert_master_detail() {

        BindingContainer bindings = getBindings();
        OperationBinding operationBinding = 
        Object result = operationBinding.execute();
        //Perform a commit on the master table binding on page view
        if (operationBinding.getErrors().isEmpty()) {
        //if transaction succeeded then continue adding data to detail

        String amDeff = "model.AppModule";
        String config = "AppModuleLocal";
        ApplicationModule am =  
               Configuration.createRootApplicationModule(amDeff, config);
        ViewObject vo = am.findViewObject("DetailTabke1");
        //connect to the detail view using the application module 
       BindingContainer bc = 
       //get the current page bindings
        JUCtrlAttrsBinding Code = 
        JUCtrlAttrsBinding Name = 
       //get list of data added to the master table that will be add to 
        the detailed table
        NameValuePairs pairs = new NameValuePairs();
        Number n=new Number(1);
        pairs.setAttribute("No", n);
        pairs.setAttribute("Status", "00020");
        pairs.setAttribute("Typee", "051");
        pairs.setAttribute("StartDate", "1430/01/01");
        pairs.setAttribute("EndDate", "1430/01/01");
        Row ActivityTaskRow = vo.createAndInitRow(pairs);
        //create a Name value attribute and calling createAndInitRow
          with name value attributes for detailed table that will be 
          used to insert row in table
        //commit the transaction and then release the connection

        return null;

This code is added as an action to submit button and should be called after creating a new row in the master table.

Wednesday, March 17, 2010

Creating dependent list of values using JDeveloper 11g

In this post I will discuses how to build a dependent list of value, in which two lists are involved.
This example is built on scott Emp/Dept tables in which it gets the list of employees working in specific department using single selection list.

So, after creating the required application using JDeveloper 11g, I created an ADF business components from tables attached to scott schema. When using the wizard it should create EMP and DEPT entities, views and a view link describing the constraints the exists between the dept_id in EMP table and dept_id in DEPT table.

The model should look somthing like the following figure, the view FKDeptnolink construct the relation between the two tables. Modify the DeptView and set OrderBy clause to order values by Dept_no, this will help to get Dept_no filed that correspond to Dept_name filed from the iterator that will be defined later in next steps.

then, create a view page in the view controller, this page will contain our list of values.
From data control drag the DeptView1 component and drop it on the page, select ADF Select One Choice component.

In the Edit List Binding, the Display Attribute select Department Name, and click ok.

Thursday, March 4, 2010

Export Datapump problem when using parallel paremeter in 10gR2 RAC database

When doing export datapump for Oracle database 10gR2 patch 2 RAC database, you should watch when using parallel parameter to export the data to more than one file at the same time.

when  running the following command it fails with an error, even it was running successfully before:
expdp system/pass@db10g schemas=test directory=TEST_DIR  
dumpfile=test_%U.dmp logfile=test.log
This reported by oracle as a bug, and as a work around you limit the parallel parameter to 1 or patch your database to higher version such as or As this was solved in these patch numbers.

expdp system/pass@db10g schemas=test directory=TEST_DIR 
dumpfile=test_%U.dmp logfile=test.log