Database Reference
In-Depth Information
IF(fmi_lname = '', NULL, fmi_lname)
);
pfmil_suffix := CONCAT_WS(', ',
IF
(prefix_fmil = '', NULL, prefix_fmil),
IF
(trim(suffix) = '', NULL, suffix || '.')
);
RETURN pfmil_suffix;
END;
$$
LANGUAGE plpgsql;
PostgreSQL PL/pgSQL provides several more syntactical variants of these condi-
tional expressions. This introduction has focused on the most commonly used ones.
For a more complete discussion of the topic, visit http://www.postgresql.org/docs/
current/static/functions-conditional.html .
Loops with counters
The PL/pgSQL language provides a simple way to loop through some elements. The
following is a function that returns the n th Fibonacci sequence number:
CREATE OR REPLACE FUNCTION fib(n integer)
RETURNS decimal(1000,0)
AS $$
DECLARE counter integer := 0;
Search WWH ::




Custom Search