Re: need help in PL/SQL trigger

From: Tim X <timx_at_spamto.devnul.com>
Date: 05 Dec 2002 09:16:04 +1100
Message-ID: <87of81e8gr.fsf_at_blind-bat.une.edu.au>


shtng <member_at_dbforums.com> writes:

> I am a newbie in SQl. I need lots of help. =)
>
> I am trying to create a trigger, when INSERT is done to add a new
> customer in CUSTOMER table, the trigger is suppose to fire and display
> messages to the user to enter more information.
> How do I display a message to the user such as "Enter Insurance info"
> and accept the input that will be entered in a table?
>

I think your trying to use triggers incorrectly here. Something like an INSERT trigger fires when data is inserted into a table and it happens at the database level, not the user interface level. Trying to interact with the user at that point would be problematic, if not impossible. for one thing, consider all the different ways you might be wanting to add data to this table - apart from diferent user interface sources (web, forms, sqlplus etc), you may have non-user interface interaction as well, such as bulk uploads, imports etc.

You are far better off handling this sort of stuff purely at the UI level and ensuring you have all the necessary data before attempting to do the insert. You could then use a trigger to prevent incomplete data being added to the table - the trigger would do some checking and if all business rules are not met, raise an exception. However, try to use database constraints to achieve as much of this checking as possible rather than the trigger (e.g. check constraints, foreign keys, not null etc) and only resort to the trigger for more complex validation which cannot be achieved via db constraints.

Tim

-- 
Tim X.
tcross (at) northnet com au
Received on Wed Dec 04 2002 - 23:16:04 CET

Original text of this message