Write a trigger that check the student_id must be start with ‘M’. PL/SQL trigger that check the student_id must be start with ‘M’
create table student_id(sno varchar2(10));
insert into student_id values(‘&sno’)
SQL> select * from student_id;
SNO
---------
1
2
3
4
set serveroutput on
create or replace trigger tri30 before insert on student_id for each row
declare
tsno student_id.sno%type;
begin
tsno:=:new.sno;
dbms_output.put_line(tsno);
if tsno not like 'M%' then
raise_application_error(-20005,'Invalid Number');
end if;
end;
No comments:
Post a Comment