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
Lightweight system to provide and take info from workers in the field and office, have basic design outlined already just require build and implementation Desired Skills CSS,

Keys in SQL SQL support for keys in the following respects: SQL does not require at least one key for every base table. If no key is explicitly declared, then KEY {ALL B

Creating a SQL file 1. Open a new file in Notepad++ and save it to the location c:\mysql\bin, with the name lab8script.sql (the file extension should be .sql ). Add a MySQL co

Closing a Cursor The CLOSE statements disable the cursor, and the result set becomes undefined. An illustration of the CLOSE statement as shown: CLOSE c1;

Package STANDARD package named STANDARD defines the PL/SQL atmosphere. The package specification globally declares the exceptions, types, and subprograms that are available a

Left and Right Joins LEFT OUTER JOIN can be used when you want to retrieve the data from the main table (table1) even if there is no match in other tables (table_2, table_3...

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, %

set serveroutput on declare a number(5); b number(5); c number(5); begin a:=&a; b:=&b; c:=a/b; dbms_output.put_line(c); exception when zero_d

Adding Table Constraints ALTER TABLE ENROLMENT ADD CONSTRAINT NameNotNull CHECK (Name IS NOT NULL) ; ALTER TABLE ENROLMENT ADD CONSTRAINT PK_StudentId_CourseId PRIM

Keyword & Parameter Description: WHEN: This keyword introduces the exception handler. You can have many exceptions execute the similar sequence of the statements by follo