Annotation: core.get_associated_units_from_item_id

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

Information: core.get_associated_units_from_item_id

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

Implementation: core.get_associated_units_from_item_id

CREATE OR REPLACE FUNCTION core.get_associated_units_from_item_id(integer)
 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_id=$1;

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

END
$function$