Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Use a trigger to remove NULL values?
CJ wrote:
> I am having some issues with an application that enters NULL values to
> an oracle 9.2 db. The application inserts multiple rows with NULL,
> which are currently removed by using standard SQL (delete) on two
> tables (table a contains the value, table b contains the relation).
>
> I therefore wonder if this would be an appropriate place to use a
> trigger?
> If yes, any examples or suggestion on how to do this?
> If no, what would be the appropriate way of automatic cleaning up this
> problem? (I can not rewrite the application)
I'm not sure I understand the problem. Do you want the db to simply ignore those insert statements that contain nulls? Is every column null, or just some?
If you want the db to simply ignore insert statements containing nulls, a trigger would work. That's kind of odd behavior, though. If I issue an insert statement, I expect it to either insert a record or return an error. Failing silently is unusual behavior, but you can certainly implement it with a trigger.
Better to simply make a not null constraint, but if this breaks your app, the trigger might make sense. You can also set a default value for the column which would get rid of the nulls, but I'm not sure if this would be what you want.
//Walt Received on Wed Feb 08 2006 - 11:12:38 CST