我正在尝试创建一个触发器,该触发器将检查我的表乘客中namesdreservation_status列中的空值,如果它为空,则将其设置为默认值,并向用户显示已将其设置为默认值的消息。
触发器已创建,并且可以很好地用于设置默认值,但不会向用户显示任何消息。
create or replace trigger mytrigger
before insert or update on passenger
for each row
when (new.reservation_status IS NULL)
begin
IF :new.reservation_status IS NULL THEN
:new.reservation_status := 'not reserved';
dbms_output.put_line('reservation status invalid, set to default');
end IF;
end mytrigger
/
如果该值为null,但消息“保留状态无效,设置为默认值”,则不显示该值。帮助。
1)确保通过菜单栏中的查看选项打开了DBMS
输出窗口。
2)单击绿色的“ +
”符号并添加您的数据库名称。
3)在过程中的第一行中写入“ DBMS_OUTPUT.ENABLE;
”。
有时step.3
是可选的,您可能不需要执行。