Example of when or then constraints - sql, PL-SQL Programming

Example of WHEN or THEN Constraints

A concrete example showing how SQL supports WHEN/THEN constraints

CREATE TABLE SAL_HISTORY (EmpNo CHAR (6),

Salary INTEGER NOT NULL,

From DATE

To DATE

PERIOD FOR During (From, To),

PRIMARY KEY (EmpNo, During WITHOUT OVERLAPS)

) ;

The PERIOD FOR specification states that the From and To values in each row denote a time interval (called a period because SQL uses the term "interval" for something else). The From values are treated as closed bounds, the To values as open bounds, so a given row in SAL_HISTORY indicates that an employee was paid a certain salary from the given From date up to but not including the given To date. The specification implies the column constraint NOT NULL NOT DEFERRABLE ENFORCED for each of columns From and To. During WITHOUT OVERLAPS, which, if required, must appear as the last element of the key, specifies that if the same EmpNo value appears in two distinct rows of SAL_HISTORY, then the From and To values in those rows must denote During periods that do not overlap (have no date in common).

Posted Date: 1/18/2013 11:34:42 PM | Location : United States







Related Discussions:- Example of when or then constraints - sql, Assignment Help, Ask Question on Example of when or then constraints - sql, Get Answer, Expert's Help, Example of when or then constraints - sql Discussions

Write discussion on Example of when or then constraints - sql
Your posts are moderated
Related Questions
Left and Right Joins LEFT OUTER JOIN can be used when you want to retrieve the data from the main table (table1) even if there is no match in other tables (table_2, table_3...

Procedures The procedure is a subprogram which can take parameters and be invoked. Normally, you can use a procedure to perform an action. The procedure has 2 sections: the spe

Database Values You can use the SELECT statement to have the Oracle assign values to a variable. For Each and every item in the select list, there must be a matching, type-compa

BEGIN Parameter Description in pl sql: BEGIN: This keyword signals the beginning of the executable section of a PL/SQL block, that contains executable statements. The execut

How Exceptions Propagate ? Whenever an exception is raised, and if the PL/SQL cannot find a handler for it in the present subprogram or block, the exception propagates. That is

UPDATE Statement   The UPDATE statement transforms the values of the specified columns in one or more rows in the table or view. Syntax:

GOTO Statement   The GOTO statement branches categorically to a block label or statement label. The label should be exclusive within its scope and should precede a PL/SQL bloc

What Is a Package? The package is a schema object that group logically related PL/SQL items, types, and subprograms. The Packages usually have 2 parts, a specification & a bo

Aggregate Assignment The %ROWTYPE declaration cannot include an initialization clause. Though, there are two ways to assign values to all fields in a record at once. At First, t

Keyword & Parameter Description: boolean_expression: This is an expression which yields the Boolean value that is TRUE, FALSE, & NULL. character_expression: This