Foreign key in form!!! [message #338150] |
Mon, 04 August 2008 00:17 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
Comii
Messages: 5 Registered: August 2008
|
Junior Member |
|
|
I’m working with Oracle Application Express 10g., and a trying to make a forms for two tables. One of that, EMPLOYEE, have a foreign key!
This is the code for tables:
CREATE TABLE "DEPARTMENT"
( "DEPARTMENT_ID" NUMBER(4,0) primary key,
"DEPARTMENT_NAME" VARCHAR2(30) NOT NULL
);
CREATE TABLE "EMPLOYEE"
( "EMPLOYEE_ID" NUMBER(6,0) PRIMARY KEY ,
"FIRST_NAME" VARCHAR2(20),
"LAST_NAME" VARCHAR2(25) NOT NULL,
"DEPARTMENT_ID" NUMBER(4,0),
CONSTRAINT "EMP_DEP_FK" FOREIGN KEY ("DEPARTMENT_ID")
REFERENCES "DEPARTMENT" ("DEPARTMENT_ID"));
I made a form for a table DEPARTMENT, and that was not problem. The problem is form for a table EMPLOYEE and a foreign key in this table DEPARTMENT_ID.
In field for a DEPARTMENT_ID I want to display in select list DEPARTMENT_NAME instead the values for DEPARTMENT_ID.
How I can do it?
Thank’s!!!
[Updated on: Mon, 04 August 2008 00:18] Report message to a moderator
|
|
|
Re: Foreign key in form!!! [message #338168 is a reply to message #338150] |
Mon, 04 August 2008 01:12 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
![](/forum/images/custom_avatars/72104.gif) |
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
You can not and should not do that; "can not" because names (which are usually letters) can not fit into a NUMBER column. "Should not" because you'd violate foreign key constraint.
The solution is to create a display item which would, well, display department name, while IDs should go into the ID item/column.
It is usually done by creating a "List of Values".
|
|
|