CREATE OR REPLACE function portal.pidentitybyusername(
    IN par_username VARCHAR
)

 RETURNS TABLE (id VARCHAR(50), username VARCHAR(50), passwordhash TEXT) 

AS 
$BODY$
BEGIN
    /*
    [7810 - Severity CRITICAL - PostgreSQL doesn't support the SET NOCOUNT. If need try another way to send message back to the client application.]
    SET NOCOUNT ON;
    */
    RETURN QUERY
    SELECT
        identityuserid AS id, i.username, i.passwordhash
        FROM dbo.identityuser AS i
        WHERE LOWER(i.username) = LOWER(par_Username);

    RETURN;
END;
$BODY$
LANGUAGE plpgsql;