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

State and explain about oracle instance?

757


How to turn on or off recycle bin for the session?

831


How to upsert (update or insert into a table)?

758


What is open database communication (odbc) in oracle?

744


How to create a table in a specific tablespace?

746


How to connect asp pages to oracle servers?

795


What is hot backup and logical backup?

824


How to experiment a data lock in oracle?

797


Point the difference between translate and replace?

844


How can I get column names from a table in oracle?

773


What are the tools for Oracle ?

825


Can I create users through internet explorer in oracle 10g?

796


Using the relations and the rules set out in the notes under each relation, write table create statements for the relations EMPLOYEE, FIRE and DESPATCH. You should aim to provide each constraint with a formal name, for example table_column_pk.

1612


Which is faster join or subquery in oracle?

737


How do we display rows from the table without duplicates?

743