0

I've created a data set with Mockaroo and then added the file with cmd. But I am getting this error. ERROR: invalid input syntax for type numeric: The table definiton is this :

create table car(
id BIGSERIAL NOT NULL PRIMARY KEY,
make VARCHAR(100) NOT NULL,
model VARCHAR(100) NOT NULL,
price NUMERIC(19,2) NOT NULL);

And this is how the numeric number (price) looks like:

insert into car (id, make, model, price) values (1, 'Mercury', 'Grand Marquis', '$52656.16');

I added the cmd screen shot for you to see.

Note : the translated version of the error written in my cmd is:

ERROR: invalid input syntax for type numeric:

p.s : I tried making (19,2) to even (50,20). It did not work.

cmd

1
  • Remove the dollar sign. It is not part of a number value. Commented Jan 10, 2021 at 14:15

2 Answers 2

1

Your price column is numeric and data that you are entering into it is varchar('$52656.16')

Either replace '$52656.16' with numeric value 52656.16 or change price column to varchar.

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

Comments

0

If you use VARCHAR for the price column you may still get a invalid input syntax for type numeric error.

What i think you should try is changing the data sets from mockaroo by changing the money option with numbers and add the decimals (you can choose 2 decimals option) option. You should have a data set without the $ sign.

1 Comment

This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review

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.