Write a trigger before insert the record of the student in the Student table.

Write a trigger before insert the record of the student in the Student

table. If the Roll_No is less than or equal to zero then the trigger

gets fired and displays the message â€Å“Invalid Roll Number”.








Write a trigger before insert the record of the student in the Student

table. If the Roll_No is less than or equal to zero then the trigger

gets fired and displays the message â€Å“Invalid Roll Number”.


--->>


 create or replace function less() returns trigger as

'

 declare


begin


if new.rollno <= 0 then 


 raise exception ''rollno is not valide'';

end if;

 return new;

 end;


'language 'plpgsql';



Create  trigger 


create  trigger vasi

before insert on student

for each row execute procedure less();


output of Trigger

Acode3=#  insert into student values (-1,'abc','fy'  );

o\p


Acode3=#  insert into student values (-1,'abc','fy'  );

ERROR:  rollno is not valide


Post a Comment

0 Comments