While exception handling, we have to write multiple repeated lines in each function to handle the GET STACKED DIAGNOSTICS values. it would be better if all items in the diagnostics may be assigned to a single variable/object.
Now we have to declare more than 5 variables to store the GET STACKED DIAGNOSTICS values and pass it to another function to record the error log. if it is in a single variable/object then it will reduce the code.
It can be a good idea, but surely with different syntax. Maybe this statement can be enhanced to use record variable as target, and then the usual syntax for composite value is
GET STACKED DIAGNOSTICS r := RETURNED_SQLSTATE, MESSAGE_TEXT, PG_EXCEPTION_DETAIL, ...