Jack Douglas
I have two tables that have deferrable foreign key constraints that refer to each other. I'd like to insert into both of these tables via a function, and it is straightforward to do this with `plpgsql`:


Is there any way of doing the same with a SQL function?
Top Answer
Jack Douglas
I'm not sure this is a sensible general solution as I suspect it may cause concurrency issues, but if you choose a dummy value that will never be present in the table you can insert that, and then update it away again, in a pure `sql` function:


Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.