Using not null-declarations in sql, PL-SQL Programming


Besides assigning an initial value, the declarations can impose the NOT NULL constraint, as the example below shows:

acct_id INTEGER(4) NOT NULL := 9999;

You cannot assign nulls to the variable define as NOT NULL. If you attempt the PL/SQL raises predefined exception VALUE_ERROR. The NOT NULL constraint should be followed by the initialization clause. For e.g. the declaration below is illegal:

acct_id INTEGER(5) NOT NULL; -- illegal; not initialized

Remember that the subtypes NATURALN and POSITIVEN are predefined as NOT NULL. For illustration, the declarations below are equivalent:

emp_count NATURAL NOT NULL := 0;
emp_count NATURALN := 0;

In the NATURALN and POSITIVEN declarations, the type specifier should be followed by an initialization clause. Or else, you get a compilation error. For e.g. the declaration below is illegal:

line_items POSITIVEN; -- illegal; not initialized

Posted Date: 10/3/2012 4:42:43 AM | Location : United States

Related Discussions:- Using not null-declarations in sql, Assignment Help, Ask Question on Using not null-declarations in sql, Get Answer, Expert's Help, Using not null-declarations in sql Discussions

Write discussion on Using not null-declarations in sql
Your posts are moderated
Related Questions
Project Description: I want somebody who can help me with an idea that I have been working on for a few months now. The person will require extensive knowledge of warcraft 3 PvP

Perform the following queries on the Hospital1.DB using SQL Anywhere (START EARLY!). a. Which patients have purchased the drug "Tylenol"? List the names and addresses. Arrange the

Entering and Exiting If you enter the executable part of an autonomous routine, the major transaction suspends. When you exit the routine, the major transaction resumes. To ex

Dynamic SQL: The Most PL/SQL programs do a predictable, specific job. For illustration, a stored procedure may accept an employee number and salary increase, and then update t

User-Defined Exceptions The PL/SQL defines the exceptions of your own. Dissimilar to the predefined exceptions, the user-defined exceptions should be declared and should be rai

Parameter and Keyword Description: cursor_name: This identifies an explicit cursor formerly declared within the present scope. cursor_variable_name: These identif

Type versus Representation Confusion in SQL This describes how a value might have two or more distinct representations. For example, user-defined type POINT might have a decla

Parameter and Keyword Description: EXIT: An unconditional EXIT statement (i.e., one without a WHEN clause) exits the present loop instantly. The Execution resumes with th

Wrapping and unwrapping in SQL Operators WRAP and UNWRAP in connection with attributes whose declared types are tuple types. Example shows how extension and projection can be

How Calls Are Resolved? The figure shows that how the PL/SQL compiler resolves the subprogram calls. When the compiler encounters the procedure or function call, it tries to di