Home » Developer & Programmer » Forms » Foreign key in form!!!
Foreign key in form!!! [message #338150] Mon, 04 August 2008 00:17 Go to next message
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
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".
Previous Topic: Locating Oracle terminal
Next Topic: Exporting Blob to PDF File
Goto Forum:
  


Current Time: Mon Feb 10 00:16:10 CST 2025