need help getting primary key from table [message #403341] |
Thu, 14 May 2009 23:12  |
callforhelp
Messages: 1 Registered: May 2009
|
Junior Member |
|
|
hey guys, I'm trying to get an automatically generated primary key from a table called Product and insert it into another table.
CREATE TABLE Product (
name VARCHAR2 ( 100 ) NOT NULL,
price NUMBER ( 5 ) NOT NULL,
quantity NUMBER ( 5 ) NOT NULL,
manufact VARCHAR2 ( 100 ) NOT NULL,
Product_ID NUMBER ( 10 ) NOT NULL,
CONSTRAINT PK_Product6 PRIMARY KEY (Product_ID)
);
CREATE TABLE Manufacturer (
name VARCHAR2 ( 100 ) NOT NULL,
price NUMBER ( 5 ) NOT NULL,
Manufacturer_ID NUMBER ( 10 ) NOT NULL,
Product_ID NUMBER ( 10 ) NOT NULL,
CONSTRAINT PK_Manufacturer7 PRIMARY KEY (Manufacturer_ID)
);
ALTER TABLE Manufacturer ADD ( CONSTRAINT FK_Manufacturer6 FOREIGN KEY (Product_ID) REFERENCES Product (Product_ID));
it complains if i try to create a row without adding in Product_ID like so:
INSERT INTO manufacturer (name,price) values ('ferrari',100)
and I can't get it to 'get' Product_ID from product like so:
INSERT INTO manufacturer (name,price,Product_ID) values ('ferrari',100,Product.Product_ID)
please help me
|
|
|
|