Thursday, April 22, 2010

Using DEFAULT

You can use the keyword DEFAULT instead of the assignment operator to initialize variables. For example, the declaration

id  CHAR := '0000';



can be rewritten as follows:

id CHAR DEFAULT '0000';

Use DEFAULT for variables that have a typical value. Use the assignment operator for variables (such as counters and accumulators) that have no typical value. A couple of examples follow:

basic_salary INTEGER DEFAULT 5000;

employee_count INTEGER := 0;

You can also use DEFAULT to initialize subprogram parameters, cursor parameters, and fields in a user-defined record.