Problem solve Get help with specific problems with your technologies, process and projects.

Trigger to insert row failed first time, but works fine after

In the Before Insert trigger, I am using a sequence (MySeq.Nextval) to generate a unique number for a not null field. This trigger is working fine, but when the user is exported and imported into different user, the first instance of writing an insert statement in that table is getting a not null constraint error. After, when I again tried to insert, it worked. What could be the reason the insert failed for first time?

I'm not exactly sure what your problem is. But I did find that there are numerous bugs that are similar to your problem for both the 8i and 9i releases. Please make sure that your database is patched to the latest patch set and check it again. This problem should not be happening, and it definitely looks like a bug. The question that remains is whether or not Oracle knows about it. If a patch set does not fix your problem, you'll have to file a TAR with Oracle Support. In the meantime, a workaround is to insert a "dummy" row and then delete it so that the trigger works properly.

For More Information

Dig Deeper on Oracle database design and architecture

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.