On Tue, Jun 18, 2024 at 3:02 PM Vitale, Anthony, Sony Music <anthony.vitale@xxxxxxxxxxxxx> wrote:
I would this this is what you are looking for
For loops and SQL injection risks, not an ideal way to write SQL programs. Though it does allow you to avoid using psql but in which case you need to do away with the \set metacommands. If you are going to use psql I strongly suggest running the select query, inspecting the results, then changing said query to use \gexec. A lot fewer moving parts that dealing with plpgsql.
Good call on making it dynamic on prokind though. And the owner matching.
Tom's got the right idea of just casting the OID for the main naming scheme - it does the SQL injection mitigation.
David J.