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

Using NOT NULL

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
Use the MASCOT tables CREDITRS, PORDS and PAYMENTS to write SQL queries to solve the following business problems. These tables / data are available to you via the USQ Oracle server

Quantification in SQL To quantify something, as the theory book has it, is to state its quantity, to say how many of it there are. For example, in Tutorial D the expression CO

Ending Transactions A good quality programming practice is to commit or roll back every transaction explicitly. Whether you rollback or issue the commit in your PL/SQL program

EXECUTE Privilege To call an invoker-rights routine straightforwardly, the users should have the EXECUTE privilege on that routine. By yielding the privilege, you permit a user

OPEN-FOR Statement The OPEN-FOR statements execute the multi-row query related with a cursor variable. It also allocates the resources used by the Oracle to process the query a

CURRVAL and NEXTVAL The series is a schema object which generates the sequential numbers. Whenever you form a sequence, you can specify its primary value and an increment. T

SELECT INTO Statement   The SELECT INTO statement retrieve data from one or more database tables, and then assigns the selected values to the variables or fields. Syntax:

Using FIRST and LAST FIRST and LAST return the first and last (minimum and maximum) index numbers in a collection. When the collection is empty, the FIRST and LAST return NULL

Multiple Assignment- SQL SQL supports multiple assignment to local variables and also applies multiple assignment semantics in SET clauses of UPDATE statements, but does not

Anatomy of a Table: Figure shows the terminology used in SQL to refer to parts of the structure of a table. As you can see, SQL has no official terms for its counterpa