Oracle
  Home arrow Oracle arrow Page 2 - Adding Computations, Processes, and Va...
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM Rational Software Development Conference
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ORACLE

Adding Computations, Processes, and Validations
By: McGraw-Hill/Osborne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2007-04-19

    Table of Contents:
  • Adding Computations, Processes, and Validations
  • Creating Validations
  • Computations
  • Creating Computations

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Dell PowerEdge Servers

    Adding Computations, Processes, and Validations - Creating Validations
    (Page 2 of 4 )

    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


       · This article is an excerpt from the "Oracle HTML DB Handbook," published by...
     

    Buy this book now. 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). Check it out today at your favorite bookstore. Buy this book now.

       

    ORACLE ARTICLES

    - Tuning PL/SQL Code
    - Debugging PL/SQL Code
    - Testing PL/SQL Code
    - Working With PL/SQL Code
    - Conditional Compilation for Oracle Database ...
    - Compile-Time Warnings for Oracle DB 10g
    - Compiling PL/SQL Code for an Oracle Database
    - Troubleshooting PL/SQL Code
    - Managing PL/SQL Code
    - Data Manipulation and More for HTML DB Appli...
    - Oracle Database Fundamentals
    - Adding Processes to HTML DB Applications
    - Adding Computations, Processes, and Validati...
    - Sub-templates and More with Oracle HTML DB
    - Focusing on Templates in Oracle HTML DB

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway