Plsql procedure for updating salary which is greater than 10000
Instead, the compiler will interpret ELSEIF as a variable or a procedure name.
The keywords THEN, ELSE, and ELSIF should not have a semicolon after them.
(As indeed they probably should, considering their employer was so inconsiderate as to lose track of their pay in the first place.)Using operators such as IS NULL and IS NOT NULL, or functions such as COALESCE and NVL2, are good ways to detect and deal with potentially NULL values.
For every variable that you reference in every Boolean expression that you write, be sure to think carefully about the consequences if that variable is NULL.
For example, you can use IS NULL to test for the presence of a NULL: In this example, “salary IS NULL” evaluates to TRUE in the event that salary has no value, and otherwise to FALSE.
Employees whose salaries are missing will now get bonuses too.
This combination implements an either/or logic: based on the condition between the IF and THEN keywords, execute the code either between THEN and ELSE or between ELSE and END IF.
One of these two sections of executable statements is performed.
Following is an implementation of the complete bonus logic described at the beginning of this chapter using the IF-THEN-ELSEIF combination: If you type ELSEIF in place of ELSIF, the compiler will also get confused and not recognize the ELSEIF as part of the IF statement.
Once the appropriate set of statements has been executed, control passes to the statement immediately following the END IF keyword.
Following is an example of the IF-THEN-ELSE construct that builds upon the IF-THEN example shown in the previous section: In this example, employees with a salary greater than ,000 will get a bonus of 0 while all other employees will get no bonus at all. What happens if salary, for whatever reason, happens to be NULL for a given employee?
Take full advantage of indents and formatting to make the logic of your IF statements easily decipherable. evaluates to FALSE or NULL, the executable statements that come after the ELSE keyword and before the matching END IF keywords are executed (the “FALSE/NULL sequence of executable statements”).
The important thing to remember is that one of the two sequences of statements will execute, because IF-THEN-ELSE is an either/or construct.