问题
Looking to throw an error where the value i'm updating is a 'not null' value.
For example. In below table, say I wanted to update Paul's lastname with 'Jackson'. The SQL should throw an error to say that the value that is being updated is 'not null'.
First Lastname
Paul Parkinson
Peter null
Turkey null
As a second part to this question, I'm actually looking to do this in the APEX Express Data Load Wizard. If anyone would know how to modify the update command to do this, it would be greatly appreciated
回答1:
You need to do this with a trigger. Example trigger:
create trigger schema.trigger_name
before update of last_name
on tablename
for each row
begin
if :old.last_name is not null then
raise_application_error (-20100, 'Last name already has a value');
end if;
end;
/
But this will stop any process that is running by raising a plsql error.
来源:https://stackoverflow.com/questions/32904466/in-sql-how-do-i-throw-an-error-when-updating-not-null-values-in-a-database-tab