473,396 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Insert Value Error

Hello everyone.

I am a newbie to Oracle 8 so please be patient and thanks for your time.
The problem is the above mentioned error. I have two databases
successully created using SQL*Plus 8.03. They are as follows:

Create Table EMPLOYEES
(
FName VARCHAR(15) NOT NULL,
MINIT CHAR,
LName VARCHAR(15) NOT NULL,
SSN CHAR(9) NOT NULL,
BDATE CHAR(25),
Address VARCHAR(30),
Sex CHAR,
Salary DECIMAL(10,2),
SUPERSSN CHAR(9),
DNO INT,
Primary Key(SSN),
Foreign Key(SUPERSSN) REFERENCES EMPLOYEES(SSN),
Foreign Key(DNO) REFERENCES DEPARTMENT(DNUMBER)
);

Create Table DEPARTMENT
(
DNAME VARCHAR(15) NOT NULL,
DNUMBER INT NOT NULL,
MGRSSN CHAR(9) NOT NULL,
MGRSTARTDATE CHAR(25),
Primary Key(DNUMBER),
Unique(DNAME),
Foreign Key(MGRSSN) References EMPLOYEES(SSN)
);

I then try to insert a record into the Employees table and received the
above mentioned error:

Insert into employees Values
('John', 'B', 'Smith', '123456789', '1965-01-09', '731 Fondren,
Houston, TX', 'M', 30000, '33344555', 5);

I then decided to try to insert a record into the Department table and
received the exact same error. I have read on google.com since the
Employees table has a foreign key which references a primary key in the
Department table I should make sure the Foreign key value exist in the
Department table first. But I'm caught in a loop because both tables
have foreign keys which point to the primary key in the other table.

Any help would be greatly appreciated.

Thanks again

Victor
Jul 19 '05 #1
2 5087
Victor M. wrote:
Hello everyone.

I am a newbie to Oracle 8 so please be patient and thanks for your time.
The problem is the above mentioned error. I have two databases
successully created using SQL*Plus 8.03. They are as follows:

Create Table EMPLOYEES
(
FName VARCHAR(15) NOT NULL,
MINIT CHAR,
LName VARCHAR(15) NOT NULL,
SSN CHAR(9) NOT NULL,
BDATE CHAR(25),
Address VARCHAR(30),
Sex CHAR,
Salary DECIMAL(10,2),
SUPERSSN CHAR(9),
DNO INT,
Primary Key(SSN),
Foreign Key(SUPERSSN) REFERENCES EMPLOYEES(SSN),
Foreign Key(DNO) REFERENCES DEPARTMENT(DNUMBER)
);

Create Table DEPARTMENT
(
DNAME VARCHAR(15) NOT NULL,
DNUMBER INT NOT NULL,
MGRSSN CHAR(9) NOT NULL,
MGRSTARTDATE CHAR(25),
Primary Key(DNUMBER),
Unique(DNAME),
Foreign Key(MGRSSN) References EMPLOYEES(SSN)
);

I then try to insert a record into the Employees table and received the
above mentioned error:

Insert into employees Values
('John', 'B', 'Smith', '123456789', '1965-01-09', '731 Fondren,
Houston, TX', 'M', 30000, '33344555', 5);

I then decided to try to insert a record into the Department table and
received the exact same error. I have read on google.com since the
Employees table has a foreign key which references a primary key in the
Department table I should make sure the Foreign key value exist in the
Department table first. But I'm caught in a loop because both tables
have foreign keys which point to the primary key in the other table.

Any help would be greatly appreciated.

Thanks again

Victor

1) DNUMBER is a "INTEGER" & therefore does NOT require signle quote
marks around it.
2) SSN is defined as CHAR(9), but count the characters!
1965-01-09
1234567890
Exactly how do you proposed to jam 10 characters into
a field that holds only NINE?
3) What prevents you from disabling one or both PK/FK pairs
while loading the data?
4) Ask the application/table designer how to load the tables!
Jul 19 '05 #2
In article <Q6pOa.120391$MJ5.69016@fed1read03>, an*******@hotmail.com
says...
Victor M. wrote:
Hello everyone.

I am a newbie to Oracle 8 so please be patient and thanks for your time.
The problem is the above mentioned error. I have two databases
successully created using SQL*Plus 8.03. They are as follows:

Create Table EMPLOYEES
(
FName VARCHAR(15) NOT NULL,
MINIT CHAR,
LName VARCHAR(15) NOT NULL,
SSN CHAR(9) NOT NULL,
BDATE CHAR(25),
Address VARCHAR(30),
Sex CHAR,
Salary DECIMAL(10,2),
SUPERSSN CHAR(9),
DNO INT,
Primary Key(SSN),
Foreign Key(SUPERSSN) REFERENCES EMPLOYEES(SSN),
Foreign Key(DNO) REFERENCES DEPARTMENT(DNUMBER)
);

Create Table DEPARTMENT
(
DNAME VARCHAR(15) NOT NULL,
DNUMBER INT NOT NULL,
MGRSSN CHAR(9) NOT NULL,
MGRSTARTDATE CHAR(25),
Primary Key(DNUMBER),
Unique(DNAME),
Foreign Key(MGRSSN) References EMPLOYEES(SSN)
);

I then try to insert a record into the Employees table and received the
above mentioned error:

Insert into employees Values
('John', 'B', 'Smith', '123456789', '1965-01-09', '731 Fondren,
Houston, TX', 'M', 30000, '33344555', 5);

I then decided to try to insert a record into the Department table and
received the exact same error. I have read on google.com since the
Employees table has a foreign key which references a primary key in the
Department table I should make sure the Foreign key value exist in the
Department table first. But I'm caught in a loop because both tables
have foreign keys which point to the primary key in the other table.

Any help would be greatly appreciated.


Thanks for the help. I am just beginning to learn Oracle on my own so
I'm bound to make mistakes.

1. For the SSN field...do I have to take into consideration the
terminator character at the end ? I suppose that is what you mean by the
added 0 at the end of the string '1234567890' ?

2. Would you tell me if this sounds right on disabling the Foreign Key
constraint in the Employees Table.

ALTER TABLE EMPLOYEES MODIFY CONSTRAINTS DNO DISABLE NOVALIDATE

Thanks again

Victor
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great...
10
by: shank | last post by:
I have a recordset that contains multiple records of product a user is purchasing. For clarity, I converted the recordset fields to variables. I need to take that entire recordset and insert it...
2
by: Tim::.. | last post by:
Can someone please tell me why I keep getting the following error from the code below! Error: INSERT statement conflicted with COLUMN FOREIGN KEY constraint...
2
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request :...
6
by: SandySears | last post by:
I am trying to use a stored procedure to insert a record using VS 2005, VB and SQL Server Express. The code runs without errors or exceptions, and returns the new identifer in the output...
2
by: technocraze | last post by:
Hi guys, I have encountered this error when updating the values to the MS Acess table. Error : Update on linked table failed. ODBC sql server error Timeout expired. MS Acess is my front end and...
6
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am...
0
ak1dnar
by: ak1dnar | last post by:
There is a Error getting while i am entering records using this jsp file. <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %> <%@ include...
2
by: DavidOwens | last post by:
<form action="do.php" method="post"> <?php /* create table users (id int, staffid int, region varchar(20), firstname varchar(20), surname varchar(20)); insert into users...
2
by: rsdev | last post by:
Hi, I have a stored procedure which is returning a blank id. Here's my code; SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings); SqlCommand cmd = new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.