7 Replies Latest reply: Mar 5, 2012 4:44 AM by 998899-Oracle RSS

    How to expose the id of the master to the detail

    998899-Oracle
      I have a master view say Employee and a detail view say EmpJobs which is a full join of both employee and jobs so that i get all the employee id and jobs id in one single view.

      My problem is that when the employee id already exiting in Employee table the detail view shows me all the pairs of employee id and jobs id.

      But in case of new insert the EmpJobs does not show me any values. Once i finish committing the data in employee table which is the master, it gives me all the pairs if i reload the page again. But i want to show all the pairs when ever create insert is pressed on the employee table.

      The id is generated using oracle.jbo.server.uniqueid.UniqueIdHelper.nextId

      Is There a way to do it?

      Thanks in advance

      I am using jdeveloper 11g release 2
        • 1. Re: How to expose the id of the master to the detail
          ramandeep singh - oracle
          You will have a reference column for the master row use that column to display the data you want to.
          • 2. Re: How to expose the id of the master to the detail
            998899-Oracle
            hi,
            Ya employee id is the link between the two.
            Actually what is happening is when i create insert on the master i.e employee an id is generated and this id is available in the child on employeeid column.

            But it is not showing all the available jobid in the full join view only after i commit it is being fetched from the database
            • 3. Re: How to expose the id of the master to the detail
              ramandeep singh - oracle
              Is it temporary id ? If that is the case the id will be temporary only. Are you using trigger based primary key for the master? If not you could also override the createandinsert action and pass the primary key value that you generated into
              createAndInitRow(NameValuePairs nvps)
              of detail row. Here in nvps you can set the reference key value to the value you generated.
              • 4. Re: How to expose the id of the master to the detail
                998899-Oracle
                Actually my use case is this

                Employee
                Empid
                1
                2


                Jobs
                Jobid
                1
                2
                3


                Select empid, jobid from employee,jobs return a full join of both
                empjobs

                empid -- jobid
                1------------1
                1------------2
                1------------3
                2------------1
                2------------2
                2------------3


                so when i create a new insert on master employee and new empid is 3

                empjobs shows

                empid -- jobid
                3

                jobid has no value.

                what i want to display is

                empid --- - jobid
                3---------------1
                3---------------2
                3---------------3

                Is there any way to do it?
                • 5. Re: How to expose the id of the master to the detail
                  998899-Oracle
                  Id which is generated is not a temperary id .It is actually the id i am committing to the database. It is generated using oracle.jbo.server.uniqueid.UniqueIdHelper.nextId
                  • 6. Re: How to expose the id of the master to the detail
                    ramandeep singh - oracle
                    Select empid, jobid from employee,jobs return a full join of both
                    I am assuming by full join you mean a full outer join.
                    I am having difficulty in understanding your structure. Is your employee having multiple jobs ? then there it is not 1 to many interaction it is many to many interaction. In a standard HR, schema the relation is many to 1. Your detail is actually not a detail then is it ?



                    sys@ORCL> desc hr.employees
                     Name                                                  Null?    Type
                     ----------------------------------------------------- -------- ------------------------------------
                     EMPLOYEE_ID                                           NOT NULL NUMBER(6)
                     FIRST_NAME                                                     VARCHAR2(20)
                     LAST_NAME                                             NOT NULL VARCHAR2(25)
                     EMAIL                                                 NOT NULL VARCHAR2(25)
                     PHONE_NUMBER                                                   VARCHAR2(20)
                     HIRE_DATE                                             NOT NULL DATE
                     JOB_ID                                                NOT NULL VARCHAR2(10)
                     SALARY                                                         NUMBER(8,2)
                     COMMISSION_PCT                                                 NUMBER(2,2)
                     MANAGER_ID                                                     NUMBER(6)
                     DEPARTMENT_ID                                                  NUMBER(4)
                    
                    sys@ORCL> desc hr.jobs
                     Name                                                  Null?    Type
                     ----------------------------------------------------- -------- ------------------------------------
                     JOB_ID                                                NOT NULL VARCHAR2(10)
                     JOB_TITLE                                             NOT NULL VARCHAR2(35)
                     MIN_SALARY                                                     NUMBER(6)
                     MAX_SALARY                                                     NUMBER(6)
                    • 7. Re: How to expose the id of the master to the detail
                      998899-Oracle
                      What you think is correct. Sorry about the explanation i gave.

                      i have actually used the detail along with a check box to insert and delete the values in many to many table (jobshistory) when it is true and false respectively.

                      detail the full join is jus for the user to see and user can pick choose what he wants to add the many to many table.

                      So i need to show all possible combination in the detail during insert so that the user can select it.