Click here to Skip to main content
15,905,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I think it is really unique for TaskId. So could you solve up my script ?

Here some error :

C#
Inserting CR_job DATA
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
*
ERROR at line 1:
ORA-02291: integrity constraint (160767CI.CR_EMPLOYEEFK) violated - parent key 
not found 


INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
*
ERROR at line 1:
ORA-02291: integrity constraint (160767CI.CR_EMPLOYEEFK) violated - parent key 
not found 


INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
*
ERROR at line 1:
ORA-02291: integrity constraint (160767CI.CR_EMPLOYEEFK) violated - parent key 
not found 


INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
*
ERROR at line 1:
ORA-02291: integrity constraint (160767CI.CR_EMPLOYEEFK) violated - parent key 
not found 



1 row created.


1 row created.

INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
*
ERROR at line 1:
ORA-02291: integrity constraint (160767CI.CR_EMPLOYEEFK) violated - parent key 
not found 



1 row created.

INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
*
ERROR at line 1:
ORA-02291: integrity constraint (160767CI.CR_EMPLOYEEFK) violated - parent key 
not found 



Commit complete.


Anyway, Sorry for my bad English. So help me Thanks :)

What I have tried:

SQL
-- Spooling Prompts: CR_task Table
PROMPT Creating CR_task Table

create table CR_task
(
	TaskId char(4),
	TaskName varchar(25) NOT NULL,
	GivenDate date NOT NULL,
	StartDate date,
	EndDate date,
	MaxHours number(3,1) DEFAULT (20.0),
	Constraint CR_taskPK PRIMARY KEY (TaskId)
);


-- Spooling Prompts: CR_job table
PROMPT Creating CR_job Table

create table CR_job
(
TaskId char(4) NOT NULL,
EmpId char(2) NOT NULL,
HoursSpent number(3,1) DEFAULT (20.0),
Constraint CR_jobPK PRIMARY KEY (TaskId, EmpId),
Constraint CR_taskFK FOREIGN KEY (TaskId) REFERENCES CR_task (TaskId),
Constraint CR_employeeFK FOREIGN KEY (EmpId) REFERENCES CR_employee (EmpId)
);

SQL
-- Spooling Prompts: CR_task inserts
PROMPT Inserting CR_task DATA

/*  Insert into CR_task */
INSERT INTO CR_task (TaskId, TaskName, GivenDate, StartDate, EndDate, MaxHours)
VALUES (1234, 'OS upgrade', '1-Feb-2016', '3-Feb-2016', '10-Feb-2016', '10');

/*  Insert into CR_task */
INSERT INTO CR_task (TaskId, TaskName, GivenDate, StartDate, EndDate, MaxHours)
VALUES (1235, 'Memory upgrade', '20-Feb-2016', '20-Feb-2016', '20-Feb-2016', '6');

/*  Insert into CR_task */
INSERT INTO CR_task (TaskId, TaskName, GivenDate, StartDate, EndDate, MaxHours)
VALUES (1236, 'Fault Analysis', '4-Mar-2016', '5-Mar-2016', '7-Mar-2016', '20');

/*  Insert into CR_task */
INSERT INTO CR_task (TaskId, TaskName, GivenDate, StartDate, EndDate, MaxHours)
VALUES (1237, 'Remove Virus', '15-Mar-2016', '16-Mar-2016', '20-Mar-2016', '40');

/*  Insert into CR_task */
INSERT INTO CR_task (TaskId, TaskName, GivenDate, StartDate, EndDate, MaxHours)
VALUES (1238, 'Printer repair', '8-Apr-2016', '10-Apr-2016', '', '20');

/*  Insert into CR_task */
INSERT INTO CR_task (TaskId, TaskName, GivenDate, StartDate, EndDate, MaxHours)
VALUES (1239, 'Cartridge replacement', '15-Apr-2016', '', '', '10');



SQL
-- Spooling Prompts: CR_job inserts
PROMPT Inserting CR_job DATA

/*  Insert into CR_job */
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
VALUES (1234, '01', '2');

/*  Insert into CR_job */
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
VALUES (1235, '08', '4');

/*  Insert into CR_job */
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
VALUES (1234, '07', '4');

/*  Insert into CR_job */
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
VALUES (1234, '09', '3');

/*  Insert into CR_job */
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
VALUES (1234, '10', '3');

/*  Insert into CR_job */
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
VALUES (1236, '12', '1');

/*  Insert into CR_job */
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
VALUES (1237, '01', '4');

/*  Insert into CR_job */
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
VALUES (1238, '12', '2');

/*  Insert into CR_job */
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
VALUES (1238, '04', '6');
Posted
Updated 8-Oct-16 0:44am
v3

1 solution

Thats not something that can be fixed in the script - you need to get your Database Administrator (DBA) to give your User ID create permissions to the database you're using
 
Share this answer
 
v3
Comments
bearforever99 8-Oct-16 6:48am    
It's working now then but I got some error...Please take a look above up...
Dave Kreskowiak 8-Oct-16 9:07am    
The error message is making it pretty obvious. You're trying to insert a record in a child table that references an ID in a parent table and that parent table record with the ID you referenced doesn't exist yet. You have to insert the parent table record first, then insert the child table record.
bearforever99 9-Oct-16 5:07am    
Just give me for example those please...i just get understand soon..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900