Store query result in a variable using in PL/pgSQL Store query result in a variable using in PL/pgSQL database database