Home arrow Oracle arrow Page 2 - Adding Computations, Processes, and Validations

Creating Validations - Oracle

Validations, computations, and processes greatly increase the functionality of an HTML DB application. In this three-part series (of which this is the first part), you'll learn about the different types and where to use them. This article is excerpted from chapter 13 of the Oracle HTML DB Handbook, written by Lawrence Linnemeyer and Bradley Brown (McGraw-Hill, 2006; ISBN: 0072257687).

TABLE OF CONTENTS:
  1. Adding Computations, Processes, and Validations
  2. Creating Validations
  3. Computations
  4. Creating Computations
By: McGraw-Hill/Osborne
Rating: starstarstarstarstar / 4
April 19, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Validations are created with a wizard, which is started by clicking on the Add icon in the Validations section on a page’s Page Definition page. The wizard can be also be started while running a page and clicking on the Create link on the Developer’s Toolbar and selecting to create a page control on this page and then choosing Validation. At the time this book was written, this second method of starting the wizard actually dropped you into the third step of the wizard, as shown here. Therefore, to specify the level of the validation and to select an item, you must use the Previous button to navigate back to the first steps in the wizard.

In the first step of the wizard, you choose the validation level, whether the validation is for an item or for the page. If you choose item-level validation, the next step allows you to specify on which item the validation will be created. Then you move on to the third step, where you select the method of the validation you wish to create.

As you can see, there are five major categories of validation methods. The SQL, PL/SQL, and Item String Comparison methods have further choices, where you specify a type within each method (see the following table for a further explanation of SQL and PL/SQL method types). The Item String Comparison types are fairly self-explanatory, so they will not be further explained.

SQL Validation Method

Method Type

Example

Exists

select 1 from a_table where check_column = :p9_an_item

Not Exists

select 1 from a_table where check_column = :p9_an_item

SQL Expression

instr(:p10_email, ‘@’)>0

PL/SQL Validation Method

Method Type

Example

PL/SQL Expression

to_char(:p9_start_date,’MON’) != ‘JAN’

PL/SQL Error

if to_char(:p9_start_date,’MON’) != ‘JAN’ then
  raise_application_error(-20001, ‘Start Date must
  be in January’);
end if;

Function Returning Boolean

Note: The validation fails when false is returned.
if to_char(:p9_start_date,’MON’) = ‘JAN’ then
  return false;
else
 
  return true;
end if;

Function Returning Error Text

Note: return null for the validation to pass.
if to_char(:p9_start_date,’MON’) = ‘JAN’ then
  return null;
else

  return ‘The Start date must be in January’ ;
end if;

The next step in the wizard allows you to specify the sequence for the validation, which determines the order in which the validation you are creating will be evaluated among all validations. You must also provide a name. Try to make the validation names descriptive (for example, P8_LASTNAME_NOTNULL). This step is also where you specify the location in which the error message will be displayed. The choices are On an Error Page, Inline with Field, Inline with Notification, and Inline with Field and in Notification. Again, I would not recommend using the error page. Whether you want to display the error message inline with its associated field will depend on your page layout. If you have multiple items on a line, sometimes this method’s results are not very appealing.

The next step is where you actually provide the implementation of the validation. It will be a little different depending on the method you selected to create. The following example shows the implementation of a Function Returning Error Text type of PL/SQL validation method.

For some methods, you will supply an item and an expression; for others, you provide code for the validation. For all types except Function Returning Error Text, you will also have to supply the text of the error message to be displayed. As you can see in the example, you can use HTML tags to spice up the display of your messages.

The final step in creating a validation is to specify the conditions under which this validation is to be evaluated. If you do not specify any conditions, the validation will be evaluated whenever the page is submitted. You can specify the validation to be evaluated when a certain button is clicked, when a certain condition exists, or both. Using both comes in real handy when implementing a multistep wizard. You would only want to evaluate your validations when the user clicks on the Next button, and you might also want to add another condition, such as to evaluate a field only if another field is a certain value.

Editing Validations

Validations can be individually edited by clicking on the name of the validation on the Page Definition page. This opens the Edit Page Validation page, where you can edit the information collected by the wizard when creating the validation. Additionally, the normal sections for Authentication, Configuration, and Comments are available.

Clicking on the Validations title of the Validation section on the Page Definition page brings up a page where you can edit the sequence, name, and display location for all your validations at the same time. You can also see the validation type for each validation as well as if the validation is conditional and when it was last updated.



 
 
>>> More Oracle Articles          >>> More By McGraw-Hill/Osborne
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

ORACLE ARTICLES

- Oracle Java Security Woes Continue
- Oracle's New IaaS Cloud Option: There's a Ca...
- Oracle Acquires Eloqua to Boost Cloud Presen...
- Choosing Innovation: Oracle Survey Insights
- Oracle Fixes Privilege Escalation Bug
- Oracle`s Communications Service Availability...
- Oracle Releases Exalytics, Taleo Plans
- Oracle Releases Communications Network Integ...
- Oracle Releases Communications Data Model 11...
- Oracle Releases PeopleSoft PeopleTools 8.52
- Oracle Integrates Cloudera Apache Distro, My...
- Oracle Releases MySQL 5.5.18
- Oracle Announces NoSQL Database Availability
- Sorting Database Columns With the SELECT Sta...
- Retrieving Table Data with the LIKE Operator

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: