Answer the question
In order to leave comments, you need to log in
How to use ON CONFLICT to track changes on INSERT?
Hello comrades! Please help me figure it out.
The PostgreSQL database has a table with the following structure:
| survey_id | employee | status (default: false) |
|--------------------------------------|---------------------|-------------------------|
| 66c89a34-fff2-4cbc-a542-b1e956a352f3 | [email protected] | true |
| 66c89a34-fff2-4cbc-a542-b1e956a352f3 | [email protected] | true |
INSERT INTO SURVEYS_EMPLOYEES_RELATIONSHIP (SURVEY_ID, EMPLOYEE)
SELECT '66c89a34-fff2-4cbc-a542-b1e956a352f3' SURVEY_ID, EMPLOYEE FROM UNNEST(ARRAY['[email protected]', '[email protected]']) EMPLOYEE
| survey_id | employee | status |
|--------------------------------------|---------------------|---------|
| 66c89a34-fff2-4cbc-a542-b1e956a352f3 | [email protected] | true |
| 66c89a34-fff2-4cbc-a542-b1e956a352f3 | [email protected] | true |
| 66c89a34-fff2-4cbc-a542-b1e956a352f3 | [email protected] | false |
| 66c89a34-fff2-4cbc-a542-b1e956a352f3 | [email protected] | false |
| survey_id | employee | status |
|--------------------------------------|---------------------|---------|
| 66c89a34-fff2-4cbc-a542-b1e956a352f3 | [email protected] | true |
| 66c89a34-fff2-4cbc-a542-b1e956a352f3 | [email protected] | false |
Answer the question
In order to leave comments, you need to log in
Is it possible to not insert records into a table that are already present in the table?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question