↑ SQL Commands Language SQL Rows 10 Clear Command Find Tables ว C Q A== 1 DECLARE 2 3 v_counter INT := 1; BEGIN 4 LOOP 5 6 78 EXIT WHEN V_counter > 5; Insert 5 rows INSERT INTO dept (did, dname) VALUES (v_counter, 'Department || v_counter); v_counter := v_counter + 1; END LOOP; COMMIT; -- Commit the changes DBMS_OUTPUT.PUT_LINE('Rows inserted into dept table.'); 9 10 11 12 END; Results Explain Describe Saved SQL History ORA-00001: unique constraint (WKSP_CS355PROJECT1.SYS_C00156739970) violated ORA-06512: at line 6 4. 5. LOOP EXIT WHEN v_counter > 5; -- Insert 5 rows 6. INSERT INTO dept (did, dname) VALUES (v_counter, 'Department '|| v_counter); 7. v_counter := v_counter + 1; 8. END LOOP: SQL Plus Oracle Database 21c Express Edition Release 21.0.0.0.0 Version 21.3.0.0.0 SQL> CREATE TABLE dept ( 2 did INT, 3 dname VARCHAR(30), 4 PRIMARY KEY (did) 5 ) ; Production Table created. SQL> SQL> CREATE TABLE emp ( 23456789 9 ) ; eid INT, ename VARCHAR(30), did INT, hiredate DATE, salary NUMBER, PRIMARY KEY (eid), FOREIGN KEY (did) REFERENCES dept (did) Table created. SQL> INSERT INTO dept VALUES (1, 'IT'); 1 row created. SQL> INSERT INTO dept VALUES (2, 'HR'); 1 row created. SQL> SQL> INSERT INTO emp VALUES (1, 'jeff', 1, DATE '2005-01-01', 70000); 1 row created. SQL> INSERT INTO emp VALUES (2, 'susan', 2, DATE '2005-06-01', 50000); 1 row created. SQL> INSERT INTO emp VALUES (3, 'bob', 1, DATE '2000-01-01', 90000); 1 row created. SQL> INSERT INTO emp VALUES (4, 'steve', 1, DATE '2006-01-01', 60000);

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

The course I'm taking is database management. 

I have attached the necessary information for this question. Please view both attachments. I need help with part A please. I am using APEX Oracle compiler.
i keep getting this error message. how do i fix this?


Part A - Using basic loop insert value into the dept table.

↑ SQL Commands
Language SQL
Rows 10
Clear Command Find Tables
ว C
Q
A==
1
DECLARE
2
3
v_counter INT := 1;
BEGIN
4
LOOP
5
6
78
EXIT WHEN V_counter > 5;
Insert 5 rows
INSERT INTO dept (did, dname) VALUES (v_counter, 'Department || v_counter);
v_counter := v_counter + 1;
END LOOP;
COMMIT; -- Commit the changes
DBMS_OUTPUT.PUT_LINE('Rows inserted into dept table.');
9
10
11
12
END;
Results Explain Describe Saved SQL History
ORA-00001: unique constraint (WKSP_CS355PROJECT1.SYS_C00156739970) violated
ORA-06512: at line 6
4.
5.
LOOP
EXIT WHEN v_counter > 5;
--
Insert 5 rows
6. INSERT INTO dept (did, dname) VALUES (v_counter, 'Department '||
v_counter);
7.
v_counter := v_counter + 1;
8.
END LOOP:
Transcribed Image Text:↑ SQL Commands Language SQL Rows 10 Clear Command Find Tables ว C Q A== 1 DECLARE 2 3 v_counter INT := 1; BEGIN 4 LOOP 5 6 78 EXIT WHEN V_counter > 5; Insert 5 rows INSERT INTO dept (did, dname) VALUES (v_counter, 'Department || v_counter); v_counter := v_counter + 1; END LOOP; COMMIT; -- Commit the changes DBMS_OUTPUT.PUT_LINE('Rows inserted into dept table.'); 9 10 11 12 END; Results Explain Describe Saved SQL History ORA-00001: unique constraint (WKSP_CS355PROJECT1.SYS_C00156739970) violated ORA-06512: at line 6 4. 5. LOOP EXIT WHEN v_counter > 5; -- Insert 5 rows 6. INSERT INTO dept (did, dname) VALUES (v_counter, 'Department '|| v_counter); 7. v_counter := v_counter + 1; 8. END LOOP:
SQL Plus
Oracle Database 21c Express Edition Release 21.0.0.0.0
Version 21.3.0.0.0
SQL> CREATE TABLE dept (
2
did INT,
3
dname VARCHAR(30),
4
PRIMARY KEY (did)
5 ) ;
Production
Table created.
SQL>
SQL> CREATE TABLE emp (
23456789
9 ) ;
eid INT,
ename VARCHAR(30),
did INT,
hiredate DATE,
salary NUMBER,
PRIMARY KEY (eid),
FOREIGN KEY (did) REFERENCES dept (did)
Table created.
SQL> INSERT INTO dept VALUES (1, 'IT');
1 row created.
SQL> INSERT INTO dept VALUES (2, 'HR');
1 row created.
SQL>
SQL> INSERT INTO emp VALUES (1, 'jeff', 1, DATE '2005-01-01', 70000);
1 row created.
SQL> INSERT INTO emp VALUES (2, 'susan', 2, DATE '2005-06-01', 50000);
1 row created.
SQL> INSERT INTO emp VALUES (3, 'bob', 1, DATE '2000-01-01', 90000);
1 row created.
SQL> INSERT INTO emp VALUES (4, 'steve', 1, DATE '2006-01-01', 60000);
Transcribed Image Text:SQL Plus Oracle Database 21c Express Edition Release 21.0.0.0.0 Version 21.3.0.0.0 SQL> CREATE TABLE dept ( 2 did INT, 3 dname VARCHAR(30), 4 PRIMARY KEY (did) 5 ) ; Production Table created. SQL> SQL> CREATE TABLE emp ( 23456789 9 ) ; eid INT, ename VARCHAR(30), did INT, hiredate DATE, salary NUMBER, PRIMARY KEY (eid), FOREIGN KEY (did) REFERENCES dept (did) Table created. SQL> INSERT INTO dept VALUES (1, 'IT'); 1 row created. SQL> INSERT INTO dept VALUES (2, 'HR'); 1 row created. SQL> SQL> INSERT INTO emp VALUES (1, 'jeff', 1, DATE '2005-01-01', 70000); 1 row created. SQL> INSERT INTO emp VALUES (2, 'susan', 2, DATE '2005-06-01', 50000); 1 row created. SQL> INSERT INTO emp VALUES (3, 'bob', 1, DATE '2000-01-01', 90000); 1 row created. SQL> INSERT INTO emp VALUES (4, 'steve', 1, DATE '2006-01-01', 60000);
Expert Solution
steps

Step by step

Solved in 1 steps

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education