I have the table in POSTGRESQL. How can insert row if in the table is not exist or update if exist by appending array in last table (Adding to the array should add new text in last column, like "1. First;" "1. First;2.Second;" "1. First;2.Second;2.Second;" etc)?
This is my code that I want to use:
INSERT INTO public.history (arm_number, dt_action)
VALUES ('1', '{"1. First;"}')
ON CONFLICT (arm_number)
DO UPDATE SET dt_action = ARRAY_APPEND(EXCLUDED.dt_action, '2. Second;');
When I use it i got only "1. First;2.Second;" What should I do?
2
Answers
I found my mistake. It was necessary to write "history.dt_action" instead of "EXCLUDED.dt_action"
Below is the final code.
Works fine over here, when using an ARRAY:
Result:
1,1. First;
1,2. Second;