0

So this happens:

enter image description here

When I try to enter another command in the prompt it just outputs another line and doesn't run the command? How do I fix this and what causes it? I figured it may be that I missed a ; in the file to end a command but I looked through my file and that wasn't so. Also in my practical sheet which teaches meh ow to write triggers:

CREATE SEQUENCE "DEPTNO_SEQ" MINVALUE 10 MAXVALUE 999999999990
INCREMENT BY 10 START WITH 10;
CREATE OR REPLACE TRIGGER "BI_DEPT"
BEFORE INSERT ON "DEPT"
FOR EACH ROW
BEGIN
 SELECT "DEPTNO_SEQ".NEXTVAL INTO :NEW.DEPTNO FROM DUAL; END;
/ 

There is an example of a trigger notice the / character at the end? What does it do? I tried loading my script with and without it and found the same problem. Also I am thinking it is a trigger problem as from the looks of the prompt it gets up to creating a sequence but doesn't create the two triggers that come after it in the file? Also I have researched about this and haven't found anything so this is my last resort. Please tell me the cause and how to fix this thanks.

user2672165
  • 2,986
  • 19
  • 27
jb3 Hd
  • 145
  • 4
  • 11
  • What does the `/` do? This is all explained in the manual: http://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_four.htm#sthref273 You also might want to have a look at this: http://stackoverflow.com/a/10207695/330315 although it just repeats what's in the manual –  Oct 18 '15 at 12:18

1 Answers1

1

The error message is trying to tell you that there's already a foreign key constraint on whatever table you're trying to modify which relates the ACTOR_ID field to ACTOR.ACTOR_ID. Oracle doesn't allow you to create a duplicate constraint.

The / is used in SQL*Plus to execute the commands which were just entered. In the example you showed the / causes the CREATE SEQUENCE and CREATE OR REPLACE TRIGGER statements to be executed. You would normally enter a / after each command to cause it to be executed. So if you're trying to get all the rows from the ACTOR table you'd do something like

SELECT * FROM ACTOR;
/

The / causes the SELECT * FROM ACTOR statement to be executed.

Best of luck.