Copyright Ó Oracle Corporation, All rights reserved Validation
18-2 Copyright Ó Oracle Corporation, All rights reserved. Objectives After completing this lesson, you should be able to do the following: Explain the effects of the validation unit upon a form List Form Builder validation properties Control validation by using triggers After completing this lesson, you should be able to do the following: Explain the effects of the validation unit upon a form List Form Builder validation properties Control validation by using triggers
18-3 Copyright Ó Oracle Corporation, All rights reserved. Validation Form Builder validates at the following levels: Form level Block level Record level Item level
18-4 Copyright Ó Oracle Corporation, All rights reserved. Validation Validation occurs when: –[Enter] key or ENTER Built-in is obeyed –Operator or trigger leaves the validation unit (includes a Commit) Validation occurs when: –[Enter] key or ENTER Built-in is obeyed –Operator or trigger leaves the validation unit (includes a Commit)
18-5 Copyright Ó Oracle Corporation, All rights reserved. Validation Unit Property
18-6 Copyright Ó Oracle Corporation, All rights reserved. LOV for Validation LOV TERRY Full list MART Partial list WARDValid Autocomplete AL ALAN HDATE FEB FEB MAR FEB SEP-81 ENAME MARTIN MARTINEZ SEDAT WARD ALAN
18-7 Copyright Ó Oracle Corporation, All rights reserved. Validation Triggers IF :S_ORD.date_shipped < :S_ORD.date_ordered THEN MESSAGE( ’ Ship Date is before Order Date! ’ ); RAISE form_trigger_failure; END IF; IF :S_ORD.date_shipped < :S_ORD.date_ordered THEN MESSAGE( ’ Ship Date is before Order Date! ’ ); RAISE form_trigger_failure; END IF; Item level When-Validate-Item Block level When-Validate-Record Item level When-Validate-Item Block level When-Validate-Record
18-8 Copyright Ó Oracle Corporation, All rights reserved. Validating User Input Trigger failure? W-V-I Customer ID 998 SELECT... WHERE id = :S_ORD.customer_id SELECT... WHERE id = :S_ORD.customer_id
18-9 Copyright Ó Oracle Corporation, All rights reserved. Tracking Validation Status NEW –When a record is created –Also for Copy Value from Item or Initial Value CHANGED –When changed by user or trigger –When any item in new record is changed NEW –When a record is created –Also for Copy Value from Item or Initial Value CHANGED –When changed by user or trigger –When any item in new record is changed
18-10 Copyright Ó Oracle Corporation, All rights reserved. Tracking Validation Status VALID –When validation has been successful –After records are fetched from database –After a successful post or commit –Duplicated record inherits status of source VALID –When validation has been successful –After records are fetched from database –After a successful post or commit –Duplicated record inherits status of source
18-11 Copyright Ó Oracle Corporation, All rights reserved. Built-ins for Validation CLEAR_BLOCK, CLEAR_ FORM, EXIT_FORM ENTER SET_FORM_PROPERTY –(..., VALIDATION) –(..., VALIDATION_UNIT) ITEM_IS_VALID item property VALIDATE (VALIDATION_ UNIT) CLEAR_BLOCK, CLEAR_ FORM, EXIT_FORM ENTER SET_FORM_PROPERTY –(..., VALIDATION) –(..., VALIDATION_UNIT) ITEM_IS_VALID item property VALIDATE (VALIDATION_ UNIT)
18-12 Copyright Ó Oracle Corporation, All rights reserved. Summary Validation occurs at item, record, block, and form levels. Validation happens when: –[Enter] Key or ENTER built-in is activated –Control leaves the validation unit due to navigation or commit Validation occurs at item, record, block, and form levels. Validation happens when: –[Enter] Key or ENTER built-in is activated –Control leaves the validation unit due to navigation or commit
18-13 Copyright Ó Oracle Corporation, All rights reserved. Summary Standard validation occurs before trigger validation. Default validation unit is item level. Validation status –NEW –CHANGED –VALID When-Validate-“object” triggers to supplement validation. Standard validation occurs before trigger validation. Default validation unit is item level. Validation status –NEW –CHANGED –VALID When-Validate-“object” triggers to supplement validation.
18-14 Copyright Ó Oracle Corporation, All rights reserved. Practice 18 Overview This practice covers the following topics: Validating the Sales Representative item value using a LOV Writing a validation trigger to check that the shipped date is not before the ordered date Populating customer names, sales representative names, and IDs when a customer ID is changed Writing a validation trigger to populate the name and the price of the product when the product ID is changed This practice covers the following topics: Validating the Sales Representative item value using a LOV Writing a validation trigger to check that the shipped date is not before the ordered date Populating customer names, sales representative names, and IDs when a customer ID is changed Writing a validation trigger to populate the name and the price of the product when the product ID is changed