PostgreSQL IF – Then syntax

IF / If Then

Syntax and examples of conditional IF – Then.

CREATE OR REPLACE FUNCTION 
	get_result(in p_name varchar(2)) 
RETURNS varchar AS $$
DECLARE
	v_name varchar(50);
BEGIN
	if p_name = 'A' then
		v_name:='The name is A';
		return v_name;
	end if;		
END;
$$ LANGUAGE 'plpgsql' IMMUTABLE;