iSelfSchooling.com - Since 1999  References  |  Job Openings
    Home  | Search more  | Oracle Syntax  | Computer Institute   | (Login or Register to access to VIDEOS)
 

Copyright & User Agreement

   Suggestions Email2aFriendHomepage us! |  Bookmark

Services

  Vision/Mission

  Services

  Biography

  Contact Us

 FREE Training

  Start...

  SQL

  PL/SQL

  Forms 

  Reports

  DBA Fundamentals

  Performance

  Prepare for OCP

  ShareUrNotes

...

  Acknowledgement

  Who is who

  University Directory

  Links...

 

 

 

FREE Online Oracle Training for beginners and advanced - The most comprehensive Oracle tutorial

The authors do not guarantee or take any responsibility for the accuracy, or completeness of the information.

BASICS

SQL | PL/SQL

DEVELOPERS

FORMS 2 | REPORTS | Other TOOLS

DBAs

FUNDAMENTALS 2 | PERFORMANCE | OEM

ADVANCE

APPLICATION SERVER | GRID CONTROL | ARTICLES 2 3 4

Advanced - Articles II

Lesson 01 | Lesson 02 | Lesson 03 | Lesson 04 | Lesson 05 | Lesson 06 | Lesson 07 | Lesson 08 | Lesson 09 | Lesson 10 | Lesson 11 | Lesson 12 | Lesson 13 | Lesson 14 | Lesson 15 | Lesson 16 | Lesson 17 | Lesson 18 | Lesson 19 | Lesson 20 | Lesson 21 | Lesson 22 | Lesson 23 | Lesson 24 | Lesson 25 | Lesson 26 | Lesson 27 | Lesson 28 | Lesson 29 | Lesson 30 | Lesson 31 | Lesson 32 | Lesson 33 | Lesson 34 | Lesson 35 |

Lesson 33

"The soul is not where it lives but where it loves."

-Thomas Fuller (1608-1661)

How to use the “WHEN-VALIDATE-ITEM” trigger?

Your client has a form that contains an item that holds a value for the “COMM-PAID-YTD” column (Commission Paid Year To Date). They want to validate the data in that column to be between 200 and 800 dollars. Anything else, it must give the following error messages:

If the commission is less than 200 then a message should be displayed as:

                ERROR: Commission must be at least $200.00 or more.

If the commission is more than 800 then a message should be:

                ERROR: Year to date commission can not exceed $800.00.

You as a programmer, asked to write a trigger to check the field item and send an error message to a user if the data entered was violated by above rules.

 

Solution:

=========

Assuming that you have a form that created by the “CUSTOMERS” table and there is an item called “COMM_PAID_YTD.”

 

1- Go to the object navigator window and expand the “COMM_PAID_YTD” item.

 

2- Highlight the “Trigger” item and click on (+) the “Create” icon.

 

3- Select the “WHEN-VALIDATE-ITEM” trigger.

 

3- Write the following procedure: 

 

IF :comm_paid_ytd < 200 THEN

    -- Must be at least $200.

    message('ERROR: Commission must be at least $200.00 or more.');

    display_error;  -- Display the message box

    raise form_trigger_failure; -- to keep the cursor in the item

ELSIF :comm_paid_ytd > 800 THEN

    -- Not more than $800.

    message('ERROR: Year to date commission can not exceed $800.00.');

    display_error; -- Display the message box

    raise form_trigger_failure;          -- to keep the cursor in the item

END IF;

 

4- Compile and close the trigger.

 

5- Run the form, go to the “COMM-PAID-YTD” item, and enter an invalid value such as 900 or 50.

 

 

 
 
Google
 
Web web site