I am working in Postgres. I have the below composite type
CREATE TYPE negotiation.diff_type AS
(
operation int,
content text
);
This is my table
CREATE temp TABLE temp_input
(
indication_request_id int,
para_id int,
line_number int,
document_id int,
modified_content text,
created_by text,
diffs diff_type[]
);
In the table I am using diffs composite type.
Below I am inserting data into the table.
INSERT INTO temp_input (myid, para_id, line_number, document_id,modified_content,created_by, diffs)
VALUES (20,2893,10,18,'my content','user1', '{(1,"DDD")"}');
This I get this error:
ERROR: malformed array literal: "{(1,"DDD")"}"
2
Answers
You need to surround each element of the array with quotes, and then escape the quotes inside the complex type’s literal:
SQLFiddle Demo
This is how you create a literal holding an array of
negotiation.diff_type
: