On Thu, Jun 3, 2021 at 1:02 PM Marc Millas <marc.millas@xxxxxxxxxx> wrote:
about knowing if I should...We have to create a set of triggers (insert, update, delete) within a huge set of tables. and that list of tables, and structure of them can be customized, maintained, ...so we were looking for a standard script to automatize the building of the whole thing, taking list of columns and constraints (for PK) directly from pg_catalog.Now it works :-)but.. why do you ask that question ? is there any king of hidden wolf we didnt see ?
Having done this (building a - limited - code generator framework using bash+psql+plpgsql) I will say that doing so using pl/pgsql, while appealing from "no extra tooling needed" perspective, doesn't play to pl/pgsql's strengths. Using a different language to generate SQL script files, which can then be executed, is probably a better way to go - if you have a different language you can build upon (i.e., not a shell scripting language like bash).
In particular, plpgsql nested strings are not fun to work with in any significant volume.
David J.