Example of not exists operator - sql, PL-SQL Programming

Assignment Help:

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 there is an alternative formulation using IS_EMPTY.

Example: MAX_ENROLMENTS expressed using an invocation of NOT EXISTS

CREATE ASSERTION MAX_ENROLMENTS_alternative1

CHECK (NOT EXISTS (SELECT *

FROM (VALUES (SELECT COUNT (*)

FROM IS_ENROLLED_ON)) AS

V (N)

WHERE V.N > 20000));

Explanation

  • VALUES ( SELECT COUNT(*) FROM IS_ENROLLED_ON ) denotes a table with just one column, unnamed, in whose single row the value of that column is the number of rows in the current value of IS_ENROLLED_ON. The SELECT expression is parenthesized to make it into a scalar subquery and given as the argument to an invocation of VALUES, which makes the number denoted by that scalar subquery into a one-row, one-column table. (Actually, it might be safer to place an extra pair of parentheses around the SELECT expression here. Although VALUES 1 and VALUES (1) are equivalent, it might not be clear as to which role the single parentheses are taking: do they denote a scalar subquery, as I have assumed, or are they the optional ones surrounding a single table expression? If the latter, we would expect a syntax error.)
  • AS V (N) defines the range variable V to refer to what in this case is just the single row of that table, and also assigns the name N to its only column.
  •  WHERE V.N > 20000 operates on that one-row, one-column table to yield a table of heading (N INTEGER) that is empty if and only if the single row in that one-row, one-column table fails to satisfy the condition N > 20000. Thus, the result is empty only when the number of enrolments is in fact no greater than the maximum allowed.

Related Discussions:- Example of not exists operator - sql

An active database in pl-sql, Consider the following set of database tables...

Consider the following set of database tables (same tables from Assignment 6-1). Please take note of foreign keys (most of them carry the same names as the corresponding primary ke

Example of unwrap operator - sql, Example of UNWRAP Operator - SQL Exa...

Example of UNWRAP Operator - SQL Example here shows how unwrapping can be done in longhand in SQL. Example: Unwrapping in SQL Letting CONTACT_INFO_WRAPPED denote the res

Using cursor attributes - bulk bind performance improvement, Using Cursor A...

Using Cursor Attributes To process the SQL data manipulation statements, the SQL engine must opens an implicit cursor named SQL. This cursor's attributes (%FOUND, %NOTFOUND, %

Rownum - sql pseudocolumns, ROWNUM The ROWNUM returns a number represe...

ROWNUM The ROWNUM returns a number representing the order in which a row was selected from the table. The first row selected has a ROWNUM of 1; the second row has a ROWNUM of

Declaring and initializing objects in pl/sql, Declaring and Initializing Ob...

Declaring and Initializing Objects: An object type is once defined and installed in the schema; you can use it to declare the objects in any PL/SQL, subprogram, block or packa

I want to build website for funding, Project Description: I want to rebu...

Project Description: I want to rebuild it and add better content to it It will include up to 5 forms The data will be saved on SQL server and the data access layer could b

Cursor variables as parameters, Cursor Variables As Parameters You can...

Cursor Variables As Parameters You can declare the cursor variables as the formal parameters of the functions and procedures. In the illustration below, you define the REF CUR

Advantages of wrapping, Advantages of Wrapping   The PL/SQL Wrapper co...

Advantages of Wrapping   The PL/SQL Wrapper convert the PL/SQL source code into a transitional form of the object code. By hiding the application internals, the Wrapper secure

Parameter aliasing, Parameter Aliasing   To optimize the subprogram ca...

Parameter Aliasing   To optimize the subprogram call, the PL/SQL compiler can decide between the two techniques of the parameter passing. With the by-value techniques, the v

Transaction control, Transaction Control The Oracle is transaction orie...

Transaction Control The Oracle is transaction oriented; that is, Oracle uses the transactions to make sure the data integrity. The transaction is a sequence of SQL data manip

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd