Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

1.

Write a database trigger halt the transaction of USER SCOTT on table EMP
CREATE OR REPLACE TRIGGER SCOTT_TRI
BEFORE INSERT OR UPDATE OR DELETE ON EMP
BEGIN
IF USER = 'SCOTT' THEN
RAISE_APPLICATION_ERROR(-20006,'TRANSACTION NOT ALLOWED FOR SCOTT');
END IF;
END;
/

2.Write a procedure to accept two different numbers and print even numbers betwe
en the two given numbers?
CREATE OR REPLACE PROCEDURE EVENNO(A NUMBER,B NUMBER)
IS
N NUMBER(4);
BEGIN
N:=A;
WHILE N<B
LOOP
IF MOD(N,2)=0 THEN
DBMS_OUTPUT.PUT_LINE(N);
END IF;
N:=N+1;
END LOOP;
END;
3.To display what operation has done on the table using triggers
trigger up_de
before update or insert or delete on emp
for each row
begin
if inserting then
dbms_output.put_line('insserting values');
elsif updating then
dbms_output.put_line('updating values');
elsif deleting then
dbms_output.put_line('deleting values');
end if;
end;

You might also like