Annotation: core.is_valid_unit

CREATE OR REPLACE FUNCTION core.is_valid_unit(_item_id integer, _unit_id integer)
RETURNS boolean

Information: core.is_valid_unit

Schema core
Function Name is_valid_unit
Arguments _item_id integer, _unit_id integer
Owner postgres
Result Type boolean
Description

Implementation: core.is_valid_unit

CREATE OR REPLACE FUNCTION core.is_valid_unit(_item_id integer, _unit_id integer)
 RETURNS boolean
 LANGUAGE plpgsql
AS $function$
        DECLARE _item_unit_id integer;
BEGIN
        SELECT unit_id INTO _item_unit_id
        FROM core.items
        WHERE item_id=$1;

        IF(core.get_root_unit_id(_item_unit_id) = core.get_root_unit_id(_unit_id)) THEN
                RETURN true;
        END IF;

        RETURN false;        
END
$function$