Assignments in pl/sql, PL-SQL Programming

Assignments in pl/sql

The Variables and constants are initialized every time a block or subprogram is entered.
By default, the variables are initialized to NULL. Therefore, unless you expressly initialize the variable, its value is undefined, as the following illustration shows:

DECLARE
count INTEGER;
...
BEGIN
count := count + 1; -- assigns a null to count


The expression on the right side of the assignment operator yield NULL as count is null. To avoid the unpredicted results, never reference the variable before you assign it a value.

You can use assignment statements to assign the values to a variable. For illustration, the statement below assigns a new value to the variable bonus, overwriting its older value:

bonus := salary * 0.15;

The expression below the assignment operator can be randomly complex, but it must yield a datatype that is similar as or convertible to the datatype of the variable.

Posted Date: 10/3/2012 5:02:25 AM | Location : United States







Related Discussions:- Assignments in pl/sql, Assignment Help, Ask Question on Assignments in pl/sql, Get Answer, Expert's Help, Assignments in pl/sql Discussions

Write discussion on Assignments in pl/sql
Your posts are moderated
Related Questions
Rephrase Conditional Control Statements When computing a logical expression, the PL/SQL uses short-circuit evaluation. That is, the PL/SQL stops evaluating the expression as s

Parameter Aliasing   To optimize the subprogram call, the PL/SQL compiler can decide between the two techniques of the parameter passing. With the by-value techniques, the v

Using Host Arrays The Client-side programs can use anonymous PL/SQL blocks to bulk-bind input and output host arrays. However, this is the well-organized way to pass the colle

Some Varray Examples In SQL Plus, assume that you define an object type Project, as described below: SQL> CREATE TYPE Project AS OBJECT ( 2 project_no NUMBER(2), 3 title VARCHA

Assignment of Variable - Updating a Variable Syntax: SET SN = SID ('S2'); This can obviously be read as "set the variable SN to be equal in value to SID ( 'S2' )".

Deleting Objects You can use the DELETE statement to eradicate objects from an object table. To eradicate objects selectively, you use the WHERE clause, as shown below: BEG

Controlling Cursor Variables You use 3 statements to control the cursor variable: OPEN-FOR, FETCH, & CLOSE. At First, you OPEN a cursor variable FOR a multi-row query. Then, y

WHEN or THEN Key Constraints Suppose a table has two columns representing a period of time throughout which the information conveyed by the other columns is recorded as having

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

Updating Variables For assignment, SQL uses the key word SET, as in SET X = X + 1 (read as "set X equal to X+1") rather than X: = X + 1 as found in many computer languages.