Can we call a trigger inside a function and function inside a
trigger? Give example.

Answer Posted / manikandan. s

triggers can't be called. They will be fired automatically
during certain operations like insert, delete, etc..

Inside a trigger we can call function

Ex

CREATE OR REPLACE FUNCTION f_t RETURN NUMBER IS
tmpVar NUMBER;
BEGIN
select sum(col2) into tmpVar from t;
RETURN tmpVar;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
RAISE;
END f_t;
/

CREATE OR REPLACE TRIGGER L4OC.T_T
AFTER INSERT
ON L4OC.T
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
declare
tmpvar number;
begin
select f_t into tmpvar from dual;
insert into t_t values(:old.col1, tmpvar);
end;
/

Is This Answer Correct ?    9 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to define an explicit cursor in oracle?

825


Define oracle database

823


Explain enable novalidate constraint.

840


How a database is related to tablespaces?

802


What are temporal data types in oracle?

888


How can you merge two tables in oracle?

778


How to call a stored function in oracle?

781


Can multiple cursors being opened at the same time?

843


Which is faster join or subquery in oracle?

757


What is blob data type in oracle?

853


Explain how are indexes update?

858


What is enter substitution variable in oracle?

812


When system tablespace is created?

811


What happens to the current transaction if the session is killed?

778


What are the different editions of oracle?

859