Re: How do I upsert depending on a second table?
От | Adrian Klaver |
---|---|
Тема | Re: How do I upsert depending on a second table? |
Дата | |
Msg-id | 22052a80-6461-4bc3-b75b-7b1063982101@aklaver.com обсуждение исходный текст |
Ответ на | Re: How do I upsert depending on a second table? (Samuel Marks <samuelmarks@gmail.com>) |
Ответы |
Re: How do I upsert depending on a second table?
|
Список | pgsql-general |
On 9/24/25 10:02, Samuel Marks wrote: > On Wed, Sep 24, 2025 at 10:13 AM Adrian Klaver > Yes but it's meant to divide by zero. That cancels the whole transaction > stopping it from going through. It being a transaction lets me guarantee > that at point of update or insert [upsert] the org owner matches the > requestor. > > I would preference a single statement (one semicolon) solution; but for > now at least this works 🤷 I don't have enough experience with below to come up with an off the top of my head examples, but they look like they may offer alternatives. MERGE: https://www.postgresql.org/docs/current/sql-merge.html and/or Row level Security: https://www.postgresql.org/docs/current/ddl-rowsecurity.html In above link see example that starts below the phrase: "... If it is necessary to consult other rows or other tables to make a policy decision, that can be accomplished using sub-SELECTs, or functions that contain SELECTs, in the policy expressions. ... " -- Adrian Klaver adrian.klaver@aklaver.com
В списке pgsql-general по дате отправления: