Oracle触发异常和回滚可能(Oracle trigger exception and rollback maybe)
假设我有以下触发器:
create or replace trigger trigInsertSaloane before insert on saloane for each row declare myExcp exception; pragma exception_init (myExcp,-20005); begin for i in (select * from saloane) loop if(:new.numar_salon=i.numar_salon) and (trim(upper(:new.nume_sectie))=trim(upper(i.nume_sectie))) then raise myExcp; end if; end loop; exception when myExcp then dbms_output.put_line('Record exists'); end; /
我想要的只是在引发异常时不插入行,所以就像回滚一样。 在我的情况下,如果引发异常并捕获,则还会插入该行。 我不想要那个。 此外,我希望以一种漂亮的方式,通过显示一条消息而不会出现任何错误。如何制作它?
Suppose I have the following trigger :
create or replace trigger trigInsertSaloane before insert on saloane for each row declare myExcp exception; pragma exception_init (myExcp,-20005); begin for i in (select * from saloane) loop if(:new.numar_salon=i.numar_salon) and (trim(upper(:new.nume_sectie))=trim(upper(i.nume_sectie))) then raise myExcp; end if; end loop; exception when myExcp then dbms_output.put_line('Record exists'); end; /
All I want is to not insert the row if exception is raised, so something like rollback. In my case if exception is raised and caught, the line is also inserted. I don`t want that. Also I want to make that in a pretty way, by showing up a message and not getting any errors.How to make it?
原文:https://stackoverflow.com/questions/37004165
最满意答案
事实上,
If Null
不接受一个字段replace by value
,而只是一个值。虽然其他解决方案也是可行的,但您可能需要使用
Modify JavaScript Value
。 根据作业给变换的参数的方式,您可能需要通过if(load_date!='null')
或者if(!load_date.isEmpty())
来替换条件。As a matter of facts the
If Null
does not accept a field in thereplace by value
, only a value.Although other solutions are possible, you may want to use a
Modify JavaScript Value
. Depending on how the the parameter is given to your transformation by the job, you may have to replace the condition byif(load_date!='null')
orif(!load_date.isEmpty())
.
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
我可以将null设置为Spring中@Value的默认值吗?(Can I set null as the default value for a @Value in Spring?)[2023-10-09]
您必须设置PropertyPlaceholderConfigurer的nullValue。 例如,我使用的字符串为@null但也可以使用空字符串作为nullValue。