Re: Oracle Portal Master Detail forms

From: DA Morgan <damorgan_at_exesolutions.com>
Date: Wed, 15 Jan 2003 08:56:09 -0800
Message-ID: <3E2592A8.9BB960B_at_exesolutions.com>


Brant Oliphant wrote:

> Yea I was trying to use the wizard may not correctly though.
>
> Let try this:
> Create master detail form using the default options (Scott.dept for master and
> Scoot.emp for detail).
> Now you can hit the query button and pass through all departments while listing
> employees in the detail form. That's all fine and great but what happens when
> you need to create a new department with new employees?
>
> 1. In the Master form: Do you have to just guess at a new deptno? Or can a
> sequence generate it for you?
> 2. In the details form: How do you get the deptno for the master form in the
> Deptno field?
> 3. How do you generate unique Empno numbers in the detail form?
>
> thanks,
> Brant
>
> DA Morgan wrote:
>
> > Brant Oliphant wrote:
> >
> > > Does anyone have documents that could help me create
> > > master detail forms. I'm creating a software tracking program for our
> > > organization. I have an order, item and vender tables.
> > > I created a master detail for were I can enter orders. In the master
> > > the Order number (primary key) is created by a sequence. In the detail
> > > view I would like to create the primary key Item number using an
> > > sequence also but the same Item number is produced for all five items.
> > > Do you know how to produce the correct Item Number? Also after the
> > > first entry my order number (primary key) and order number (foreign key)
> > >
> > > get out of sequence.
> > >
> > > Thanks for the help,
> > > Brant
> > >
> > > I attached the form, my be it will clear things up.
> > >
> > > Below is the text file to create tables:
> > >
> > > CREATE TABLE MANUFACTURE(
> > > MAN_ID NUMBER(5) NOT NULL,
> > > NAME VARCHAR2(50),
> > > WebSite VARCHAR2(50),
> > > Sales_Phone VARCHAR2(20),
> > > Sales_Email VARCHAR2(50),
> > > Tec_Phone VARCHAR2(20),
> > > Tec_Email VARCHAR2(50),
> > > Address VARCHAR2(50),
> > > City VARCHAR2(20),
> > > State VARCHAR2(20),
> > > Zip VARCHAR2(10),
> > > Notes VARCHAR2(512),
> > > CONSTRAINT MAN_PK PRIMARY KEY (Man_ID));
> > >
> > > CREATE SEQUENCE MAN_ID
> > > INCREMENT BY 1
> > > START WITH 30000
> > > NOCACHE;
> > >
> > > CREATE TABLE VENDER (
> > > VENDER_ID NUMBER(5) NOT NULL,
> > > NAME VARCHAR2(50),
> > > WebSite VARCHAR2(50),
> > > Sales_Phone VARCHAR2(20),
> > > Sales_Email VARCHAR2(50),
> > > Tec_Phone VARCHAR2(20),
> > > Tec_Email VARCHAR2(50),
> > > Address VARCHAR2(50),
> > > City VARCHAR2(20),
> > > State VARCHAR2(2),
> > > Zip VARCHAR2(10),
> > > Notes VARCHAR2(512),
> > > CONSTRAINT VENDER_PK PRIMARY KEY (VENDER_ID));
> > >
> > > CREATE SEQUENCE VENDER_ID
> > > INCREMENT BY 1
> > > START WITH 40000
> > > NOCACHE;
> > >
> > > CREATE TABLE SOFTORDER (
> > > Order_ID NUMBER(5) NOT NULL,
> > > ODate Date,
> > > Invoice VARCHAR2(25),
> > > Payment_Method VARCHAR2(20),
> > > Notes VARCHAR2(512),
> > > Vender_ID NUMBER(5),
> > > ManIsVen_ID NUMBER(5),
> > > CONSTRAINT ORDER_FK FOREIGN KEY (Vender_ID) REFERENCES VENDER
> > > (VENDER_ID),
> > > CONSTRAINT ManIsVen_FK FOREIGN KEY (ManIsVen_ID) REFERENCES MANUFACTURE
> > > (MAN_ID),
> > > CONSTRAINT ORDER_PK PRIMARY KEY (Order_ID));
> > >
> > > CREATE SEQUENCE Order_ID
> > > INCREMENT BY 2
> > > START WITH 1
> > > NOCACHE;
> > >
> > > CREATE TABLE SoftItem (
> > > Item_ID NUMBER(5) NOT NULL,
> > > IName VARCHAR2(50),
> > > Lic_Name VARCHAR2(50),
> > > Price NUMBER(9,2),
> > > Quantity NUMBER(4,0),
> > > Serial_Num VARCHAR2(50),
> > > Expire_Date Date,
> > > Lincense_Key VARCHAR2(512),
> > > Notes VARCHAR2(512),
> > > Man_ID NUMBER(5) NOT NULL,
> > > Order_ID NUMBER(5) NOT NULL,
> > > CONSTRAINT Man_Item_FK FOREIGN KEY (Man_ID) REFERENCES
> > > MANUFACTURE(Man_ID),
> > > CONSTRAINT Order_Item_FK FOREIGN KEY (Order_ID) REFERENCES SOFTORDER
> > > (Order_ID),
> > > CONSTRAINT Item_PK PRIMARY KEY (Item_ID));
> > >
> > > CREATE SEQUENCE Item_ID
> > > INCREMENT BY 2
> > > START WITH 2
> > > NOCACHE;
> >
> > Create the master block
> >
> > Then use the wizard to create the child block. If you read the options
> > presented to you by the wizard you will find that it only takes a few mouse
> > clicks.
> >
> > I do not recommend doing it manually.
> >
> > Daniel Morgan

  1. A sequence can be used. Either in the database or in forms you can use sequence_name.NEXTVAL
  2. Oracle migrates the primary key as part of the master-detail relationship.
  3. Same as you do in the database ... use a sequence or any other method.

My preference in all of the above is to use a database package to hold as much code as possible so as to keep the form lean.

Daniel Morgan Received on Wed Jan 15 2003 - 17:56:09 CET

Original text of this message