I try to insert data into one of the table causes but I got an error message, I don't know how to resolve this
SQL> CREATE TABLE Causes(cid NUMBER(5) PRIMARY KEY, name VARCHAR2(20) REFERENCES Signup, problem VARCHAR2(256), location VARCHAR2(200),fund NUMBER(30));
Table created.
SQL> CREATE TABLE Causes(cid NUMBER(5) PRIMARY KEY, name VARCHAR2(20) REFERENCES Signup, problem VARCHAR2(256), location VARCHAR2(200),fund NUMBER(30));
Table created.
SQL> describe Signup;
Name
Null? Type
----------------------------------------- --------
----------------------------
USERNAME
NOT NULL VARCHAR2(50)
PASSWORD
VARCHAR2(50)
NAME
NOT NULL VARCHAR2(100)
AGE
NUMBER(5)
PHONE
CHAR(20)
ADDRESS
VARCHAR2(200)
SQL> describe Causes;
Name
Null? Type
----------------------------------------- --------
----------------------------
CID
NOT NULL VARCHAR2(5)
NAME
VARCHAR2(20)
PROBLEM
VARCHAR2(256)
LOCATION
VARCHAR2(200)
FUND
ERROR MESSAGE :
SQL> insert into Causes values(100, 'kamal', 'floods',
'australia', 2000);
ERROR at line 1:
ORA-02291: integrity constraint (GILLIK.SYS_C0063904) violated -
parent key not found
ORA-02291 is typically accompanied with the message, “integrity constraint (GILLIK.SYS_C0063904) violated – parent key not found”. This means that you attempted to execute a reference to a certain table using a primary key. However, in the process of doing so, the columns that you specified failed to match the primary key. The error can also be triggered when referencing a primary key that does not exist for the table in question.
In order to remedy this error, you will need to insert the value that you attempted to place in the child table into the parent table first. Once inserted as a parent row, you can go back and insert the value into the child table.
So, first you need to insert your data in Signup Table after than you can insert your data in Causes table.
I try to insert data into one of the table causes but I got an error...
/* I am executing following SQL statement for the below code but I am getting error. Pls, upload screenshot after running it. SQL Statement: SELECT OfferNo, CourseNo FROM Offering WHERE OfferTerm = 'Sum' AND OfferYear = 2012 AND FacSSN IS NULL; */ CREATE TABLE STUDENT( StdSSN INT NOT NULL PRIMARY KEY, StdFName VARCHAR2(50), StdLName VARCHAR2(50), StdCity VARCHAR2(50), StdState VARCHAR2(2), StdZip VARCHAR2(10), StdMajor VARCHAR2(15), StdYear VARCHAR2(20) ); CREATE TABLE FACULTY( FacSSN INTEGER NOT NULL PRIMARY KEY, FacFName VARCHAR(50), FacLName VARCHAR(50), FacCity...
Using the code below in Oracle SQL Live I keep getting an error message for the last 4 INSERTS. The error message is: ORA-00932: inconsistent datatypes: expected DATE got NUMBER. How do I correct that error? CREATE TABLE BASE ( BASENUM CHARACTER(3) NOT NULL, BASECITY varchar(20), BASESTATE CHARACTER(2), BASEPHON varchar(10), BASEMGR varchar(10), PRIMARY KEY (BASENUM) ); CREATE TABLE TYPE ( TYPENUM CHARACTER(1) NOT NULL, TYPEDESC varchar(30), PRIMARY KEY (TYPENUM) ); CREATE TABLE TRUCK ( TNUM CHARACTER(4) NOT NULL, BASENUM CHARACTER(3),...
Use the COMMIT statement to save changes in the table created in the above database. Use the SELECT * FROM your_table_name; command to display the content of the table (make sure to substitute your_table_name with the actual name of your table). Use the ROLLBACK command to undo changes in the table created in the above database. What happened? Why? Use the SELECT * FROM your_table_name; command to display the content of the table (make sure to substitute your_table_name with the...
Create a procedure to update the sales history table following the requirements below. A table creation script is provided below. a) Call the procedure: UPDATE_SALES_HISTORY (The procedure name is important for our scripts to test and grade your code; please do not rename it (otherwise our scripts will not run and your score will be 0). b) The procedure takes 2 parameters: (4-digit-year, 2-digit-month). Both parameters will be numeric, e.g., (2019, 11) will denote 2019 (year) and November (month). The...
drop table department cascade constraints; create table department ( Dname varchar2(15) not null, Dnumber int not null, Mgr_ssn char(9) not null, mgr_start_date Date, primary key (Dnumber), Unique (Dname)); insert into DEPARTMENT values ('Research', '5', '333445555', '22-May-1988'); insert into DEPARTMENT values ('Administration', '4', '987654321', '01-Jan-1995'); insert into DEPARTMENT values ('Headquarters', '1', '888665555', '19-Jun-1981'); drop table employee cascade constraints; create table employee ( Fname varchar2(15) not null, Minit char(1), Lname varchar2(15) not null, Ssn char(9), Bdate date, Address varchar2(30), Sex char(1),...
I need help for SQL homework. the question: the code for part 1,2: drop table Customer; drop table Company; drop table Cruise; drop table TravelAgent; drop table Reservation; drop sequence customerID_seq; drop sequence cruiseID_seq; drop sequence travelAgentID_seq; drop sequence reservationID_seq; create table Customer( customerID number, firstName varchar2(15), lastName varchar2(15), address varchar2(30), phone number(10) not null, age number(3), Constraint Customer_PK Primary Key (customerID), constraint Customer_unique unique (firstName,lastName,phone), constraint Customer_check check(phone is not null) ); create sequence customerID_seq start with 1 increment...
Tables: Create table Item( ItemId char(5) constraint itmid_unique primary key, Decription varchar2(30), Unitcost number(7,2)); Create table Customer( custID char(5) constraint cid.unique primary key, custName varchar2(20), address varchar2(50)); Create table Orderdata( orderID char(5) constraint oid_uniq primary key, orderdate date, shipdate date, ItemId char(5) references Item.ItemId, No_of_items number(4), Unitcost number(7,2), Order_total number(7,2), custID char(5) references customer.custID); Insert Into Item values(‘A123’,’Pencil’,2.5); Insert Into Item values(‘B123’,’Pen’,15); Insert Into...
Provide the syntax answers for the following script, doesn't matter what table or columns. CREATE TABLE customer (c_id NUMBER(5), c_last VARCHAR2(30), c_first VARCHAR2(30), c_mi CHAR(1), c_birthdate DATE, c_address VARCHAR2(30), c_city VARCHAR2(30), c_state CHAR(2), c_zip VARCHAR2(10), c_dphone VARCHAR2(10), c_ephone VARCHAR2(10), c_userid VARCHAR2(50), c_password VARCHAR2(15), CONSTRAINT customer_c_id_pk PRIMARY KEY (c_id)); CREATE TABLE order_source (os_id NUMBER(3), os_desc VARCHAR2(30), CONSTRAINT order_source_os_id_pk PRIMARY KEY(os_id)); CREATE TABLE orders (o_id NUMBER(8), o_date DATE, o_methpmt VARCHAR2(10), c_id NUMBER(5), os_id NUMBER(3), CONSTRAINT orders_o_id_pk PRIMARY KEY (o_id), CONSTRAINT orders_c_id_fk FOREIGN...
DROP TABLE EMPLOYEE; DROP TABLE JOB; DROP TABLE EMP; DROP TABLE EMP_1; DROP TABLE EMP_2; CREATE TABLE JOB(JOB_CODE CHAR (3) PRIMARY KEY, JOB_DESCRIPTION VARCHAR (20) NOT NULL,JOB_CHG_HOUR NUMBER (5,2) NOT NULL,JOB_LAST_UPDATE DATE NOT NULL); INSERT INTO JOB VALUES('500','Programmer','35.75','20-Nov-2017'); INSERT INTO JOB VALUES('501','System Analyst','96.75','20-Nov-2017'); INSERT INTO JOB VALUES('502','Database Designer','125.00','24-Mar-2018'); CREATE TABLE EMPLOYEE(EMP_NUM CHAR (3) PRIMARY KEY,EMP_LNAME VARCHAR (15) NOT NULL,EMP_FNAME VARCHAR (15) NOT NULL, EMP_INITIAL CHAR (1),EMP_HIREDATE DATE NOT NULL,JOB_CODE CHAR (3), EMP_YEARS NUMBER (2),FOREIGN KEY (JOB_CODE) REFERENCES JOB (JOB_CODE)); INSERT...
I am using oracle sql developer to create some queries to generated reports and it is not working. I am not sure how to use count, group by, and order by. Help me fix my query and explain to me how you did, so can do it next time. Also, I have to convert this query to a stored procedure, so can you help me do it too? Here is my query: SELECT COUNT(GUEST.FIRSTNAME), GUEST.FIRSTNAME, GUEST.LASTNAME, GUEST.GUESTTYPE, RESERVATION.RESERVATIONDATE, GUEST.EMAIL, FROM...