Annotation: core.get_associated_units_from_item_code

CREATE OR REPLACE FUNCTION core.get_associated_units_from_item_code(text)
RETURNS TABLE(unit_id integer, unit_code text, unit_name text)

Information: core.get_associated_units_from_item_code

Schema core
Function Name get_associated_units_from_item_code
Arguments text
Owner postgres
Result Type TABLE(unit_id integer, unit_code text, unit_name text)
Description

Implementation: core.get_associated_units_from_item_code

CREATE OR REPLACE FUNCTION core.get_associated_units_from_item_code(text)
 RETURNS TABLE(unit_id integer, unit_code text, unit_name text)
 LANGUAGE plpgsql
AS $function$
	DECLARE _unit_id integer;
BEGIN
    SELECT core.items.unit_id INTO _unit_id
    FROM core.items
    WHERE core.items.item_code=$1;

    RETURN QUERY
    SELECT ret.unit_id, ret.unit_code, ret.unit_name
    FROM core.get_associated_units(_unit_id) AS ret;
END
$function$