Replaced SQL functions' params with named params

Changed SQL functions to use named parameters instead of positional parameters, which improves readability. Named params are implemented in all currently supported versions of Postgresql.