Third step at defining type sid in sql, PL-SQL Programming

Assignment Help:

Third Step at defining type SID in SQL

CREATE DOMAIN SID AS VARCHAR(5)

CHECK ( VALUE IS NOT NULL AND

SUBSTRING(VALUE FROM 1 FOR 1) = 'S' AND

CAST('+'||SUBSTRING(VALUE FROM 2) AS INTEGER) >= 0 );

Explanation:

  1. DOMAIN SID announces that a domain named SID is being defined to the system.
  2. AS VARCHAR(5) specifies that values in domain SID are certain values of type VARCHAR(5).
  3. CHECK ( ... ) specifies a constraint defining exactly which values of type VARCHAR(5) are in the domain SID. Note that the key word VALUE, which is available only in domain constraints, refers (in this particular example) to an arbitrary value of type VARCHAR(5).
  4. VALUE IS NOT NULL specifies that the null value of type VARCHAR(5) is not a value in the domain. This is needed because the other conjuncts evaluate to UNKNOWN if VALUE is the null value and a domain constraint is deemed to be violated only when it evaluates to FALSE.
  5. SUBSTRING(VALUE FROM 1 FOR 1) = 'S' specifies that every value in the domain must begin with S. Note SQL's deliberate use of "noise" words in the invocation of SUBSTRING, the justification for which is to distinguish invocations of system-defined operators from those of user-defined ones.
  6. CAST('+'||SUBSTRING(VALUE FROM 2) AS INTEGER) >= 0 is an attempt to emulate an invocation of IS_DIGITS, perhaps showing how a user-defined operator of that name might be implemented in SQL. The character "+" is concatenated to the putatively numeric portion of the string in order to exclude values such as 'S+123' from the domain (the string '+123' can be cast as an integer but '++123' cannot).

Related Discussions:- Third step at defining type sid in sql

Mutual recursion, Mutual Recursion The Subprograms are mutually recursi...

Mutual Recursion The Subprograms are mutually recursive if they directly or indirectly call each other. In the illustration below, the Boolean functions odd & even, that dete

Sql queries-oracle , 1- You can check attribute names from each table in D...

1- You can check attribute names from each table in DBF11 by running for example:  desc dbf11.Member;  desc dbf11.Agent;  desc dbf11.Producer; Because some attribute names in

Accessing attributes in pl sql, Accessing Attributes: You can refer to ...

Accessing Attributes: You can refer to an attribute only by its name not by its position in the object type. To access or modify the value of an attribute, you can use the dot

Structure of an object type in pl/sql, Structure of an Object Type: Si...

Structure of an Object Type: Similar to package, an object type has 2 parts: the specification and the body. The specification is the interface to your applications; it declar

Second step at defining type sid in sql, Second Step at defining type SID i...

Second Step at defining type SID in SQL CREATE TYPE SID AS VARCHAR(5) ; Explanation: TYPE SID announces that a type named SID is being defined to the system.

Package specification in pl/sql , Package Specification The package sp...

Package Specification The package specifications contain the public declarations. The scopes of these declarations are local to your database representation and global to the

Assigning and comparing collections, Assigning and Comparing Collections ...

Assigning and Comparing Collections One collection can be assigned to other by an SELECT, INSERT, UPDATE, or FETCH statement, an assignment statement, or by a subprogram call. A

In packages - subprograms, In Packages The Forward declarations also g...

In Packages The Forward declarations also group logically related subprograms in the package. The subprogram specifications go in the package specification, & the subprogram b

Name resolution-naming conventions, Name Resolution In potentially uncer...

Name Resolution In potentially uncertain SQL statements, the names of the database columns take precedence over the names of the local variables and formal parameters. For e.g.

I want customer management program, This is a Customer Management project. ...

This is a Customer Management project. Customer data is presented in a text file. The program will load this text data into its DB columns. The data mapping is user definable. User

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