반응형
/****************************************************************************************************************
-- Title : [PGS9.2] General function call of returning string
-- Reference : www.postgresql.com
-- Key word : function 함수
****************************************************************************************************************/
CREATE OR REPLACE FUNCTION concat_lower_or_upper (a text, b text, uppercase boolean DEFAULT false)
RETURNS text
AS
$$
SELECT CASE WHEN $3 THEN UPPER ($1 || ' ' || $2)
ELSE LOWER ($1 || ' ' || $2)
END;
$$ LANGUAGE SQL IMMUTABLE STRICT;
select concat_lower_or_upper('hello', 'World', true);
select concat_lower_or_upper('hello', 'World');
select concat_lower_or_upper('hello', 'World', false);
SELECT concat_lower_or_upper (a := 'Hello', b := 'World');
SELECT concat_lower_or_upper (a := 'Hello', uppercase := true, b := 'World');
SELECT concat_lower_or_upper ( 'Hello', 'World', uppercase := true);
반응형