Annotation: office.get_logged_in_office_id

CREATE OR REPLACE FUNCTION office.get_logged_in_office_id(_user_id integer)
RETURNS integer

Information: office.get_logged_in_office_id

Schema office
Function Name get_logged_in_office_id
Arguments _user_id integer
Owner postgres
Result Type integer
Description

Implementation: office.get_logged_in_office_id

CREATE OR REPLACE FUNCTION office.get_logged_in_office_id(_user_id integer)
 RETURNS integer
 LANGUAGE plpgsql
AS $function$
BEGIN
    RETURN
    (
        SELECT office_id
        FROM audit.logins
        WHERE user_id=$1
        AND login_date_time = 
        (
            SELECT MAX(login_date_time)
            FROM audit.logins
            WHERE user_id=$1
        )
    );
END
$function$