by Horatiu Dan
There aren’t few the situations when applications are requested to be agile and versatile enough so that they can run dynamic reports for which the input comes at runtime.
This post aims to present a way of achieving it by leveraging the temporary configuration parameters supported by PostgreSQL databases.
According to the PostgreSQL documentation, starting with version 7.3, it is possible to set a configuration parameter using the set_config(name, value, is_local) function. Later, the value of the previously set parameter may be read using the current_setting(name) function, converted if needed and used. If the third parameter of the former function is true, the changed setting will only apply to the current transaction.
This is exactly what is needed here, a way of providing a runtime parameter value that can be used as part of an atomic operation.
Set-UpThe sample application is build with:
...