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 do you get nicely formatted results from an oracle procedure that returns a reference cursor?

539


How many types of auditing in Oracle?

556


Explain the blob datatype?

610


Why is oracle used?

544


How to write a left outer join with the where clause in oracle?

619






how to handle exceptions in post production

935


What is a tns file?

493


Is rowid unique in oracle?

512


Explain index?

731


When do you get a .pll extension in oracle? Explain its importance

566


How to concatenate two text values in oracle?

587


State and explain the different types of data models?

525


Explain the function of optimizer in oracle?

582


Difference between inner join vs where ?

598


How to assign a table row to a record variable?

571