Commit b62c72d4 authored by Adrien Di Mascio's avatar Adrien Di Mascio
Browse files

[sql] provide plpgsql versions of stored procedures to avoid unncessary plpythonu dependency

parent df6b7f0769bc
/* -*- sql -*- /* -*- sql -*-
postgres specific registered procedures, postgres specific registered procedures,
require the plpythonu language installed require the plpgsql language installed
*/ */
CREATE FUNCTION phonetype_sort_value(text) RETURNS int CREATE OR REPLACE FUNCTION NAME(login VARCHAR, firstname VARCHAR, surname VARCHAR) RETURNS VARCHAR
AS 'return {"mobile":2, "home":1, "office":4,"fax":0, "secretariat":3}[args[0]]' AS $$
LANGUAGE plpythonu; BEGIN
IF firstname IS NULL OR firstname = '' THEN
RETURN login;
ELSEIF surname IS NULL OR surname = '' THEN
RETURN firstname;
ELSE
RETURN firstname || ' ' || surname;
END IF;
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION PHONETYPE_SORT_VALUE(phonetype varchar) RETURNS int
AS $$
BEGIN
IF phonetype = 'fax' THEN
RETURN 0;
ELSIF phonetype = 'home' THEN
RETURN 1;
ELSIF phonetype = 'mobile' THEN
RETURN 2;
ELSIF phonetype = 'secreatariat' THEN
RETURN 3;
ELSE
RETURN 4;
END IF;
END;
$$ LANGUAGE plpgsql;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment