Database Reference
In-Depth Information
The result with 40 marks can be seen using the following statement:
warehouse_db=# SELECT search_case(40);
search_case
-------------
PASS
(1 row)
Loops
Match the condition, perform the desired task, and just keep doing this because
you are executing loops. It is one of the powerful programming constructs that
makes life easier when it comes to performing repetitive tasks on logical results of
certain conditions. PL/pgSQL comes up with a variety of loop constructs that surely
expands its scope to address and meet high-level requirements.
The simple loop
The simple loops are composed of an unconditional loop that ends only with an EXIT
statement. Remember that EXIT can be used with all loop constructs, not only with
an unconditional loop. The syntax for a simple loop is as follows:
LOOP
Statements
END LOOP;
The syntax for EXIT is as follows:
EXIT WHEN boolean-expression;
If no label is given to an EXIT command, the innermost loop is terminated.
LOOP
result = result-1;
IF result > 0 THEN
-- exits loop
EXIT;
END IF;
END LOOP;
The other way to use EXIT is as follows:
LOOP
result = result -1
EXIT WHEN result > 0;
END LOOP;
 
Search WWH ::




Custom Search