Conditionals - sql, PL-SQL Programming

Conditionals - SQL

At first sight SQL does not appear to have a single operator for expressing logical implication. In this respect it would be in common with most programming languages, including Tutorial D. However, standard SQL defines a partial ordering for its three truth values, under which false is deemed to precede true. Thus, the comparisons p < q, p > q, p <= q, and p >= q are all supported in standard SQL (in addition to p = q, of course).

it is noted that in 2VL p → q is equivalent to ¬ p ∨ q. Study of Figure 3.5 reveals that ¬ p ∨ q does indeed equate to p → q when neither operand is unknown, and the same is true of p <= q! (It is the pronunciation, "is less than or equal to", rather than "implies", that led to my observation that SQL appears to include direct support for a 3VL form of implication by accident.)

1570_Conditionals - SQL.png

Figure: The SQL Truth Tables for ¬ p∨ q and p <= q

Note, however, that p <= q is not equivalent to ¬ p ∨ q. Intuitively, we understand that "p implies q" is true whenever q is true. This holds for ¬ p ∨ q but not for p <= q, as the row for p = U and q = T shows. The U in the last column for that row arises from SQL's general rule that whenever an operand of a comparison is NULL, the result is unknown-and NULL, when it is the result of evaluating a Boolean expression, is considered synonymous with unknown. In fact, Figure gives a demonstration of the fact that SQL is not always faithful to its own concept, that NULL represents "a value exists here but we don't know which value". What U really means when it appears in the column for p <= q is that <= is undefined for that particular pair of truth values.

Posted Date: 1/18/2013 4:16:23 AM | Location : United States

Related Discussions:- Conditionals - sql, Assignment Help, Ask Question on Conditionals - sql, Get Answer, Expert's Help, Conditionals - sql Discussions

Write discussion on Conditionals - sql
Your posts are moderated
Related Questions
DBMS_PIPE: The Package DBMS_PIPE allows various sessions to communicate over the named pipes. (A pipe is a region of memory used by one of the process to pass information to

Using Cursor Attributes: Every cursor has 4 attributes: %NOTFOUND, %FOUND, %ISOPEN, and %ROWCOUNT. If appended to the cursor name, they return the helpful information about

Example of NOT EXISTS Operator - SQL Example is a translation into SQL of the corresponding example, which is included there merely to show that for any scalar comparison the

THEO R Y OF CATASTROPHISM OR CATALYSM (CUVIER 1769-1832) - The world has passed thorugh several stages and at the end of each stage there was a catastrophe killing all the

Implicit Cursor Attributes The Implicit cursor attributes returns the information about the execution of an INSERT, DELETE, UPDATE, or SELECT INTO statement. The cursor attribu

The Package Body The package specification is implemented by the package body. That is, the package body has the definition of every cursor and the subprogram declared in the p

%TYPE Attribute The %TYPE attribute gives the datatype of a record, field, nested table, database column, or the variable. You can use the %TYPE attribute as the datatype speci

Processing Transactions This part describes how to do the transaction processing. You learn the fundamental techniques that safeguard the consistency of your database, involvin

CLOSE Statement The CLOSE statement allows the resources held by a cursor variable or open cursor to be reused. No more rows can be fetched from the cursor variable or closed

Functions   The function is a subprogram that calculates a value. The Functions and procedures are structured similar, except that the functions have a RETURN clause. You can