1

We are trying to import tables into PostgreSQL from SQL Server. In source data, there are tables with a JSon column storing nested information for parent record in Master Detail fashion. For example, for one Order, there can be multiple properties stored in JSon Column in the same row.

While this approach worked well for SQL Server, in trying to do the same on PostgreSQL, we are running into an error "ERROR: invalid input syntax for type json" DETAIL: Expected end of input, but found ",".

Has anyone encountered a similar situation and if so, can you suggest the right way to achieve the desired result. You can refer to the following insert statement as example.

INSERT INTO "customer" 
            ("name", 
             "id", 
             "details") 
VALUES     ("abc", 
            1, 
            '{"PhoneNO":"987654321","Gender":"Female"},{"PhoneNO: "98123456"} ') 

1 Answer 1

1

There is a missing double quote for "PhoneNO and there are missing brackets:

create table "Customer" (
"NAME" varchar,
"ID" int,
"details" json 
);
CREATE TABLE

INSERT INTO "Customer" ("NAME", "ID", "details") VALUES('ABC',1, '[{"PhoneNO":"987654321","Gender":"Female"},{"PhoneNO": "98123456"}]');
INSERT 0 1

And you cannot use "..." for VARCHAR literals: you must use '...'.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.