Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why does this happen when I insert a date value into a table? ERROR: value too long for type character varying(30) – PostgreSQL

I am trying to insert a DATE type value into a table. For that to happen, I used this line of code:

insert into funcionario (primeiro_nome, nome_meio, ultimo_nome, cpf, data_nascimento, endereco, sexo, salario, numero_departamento)
values ('João', 'B', 'Silva', 12345678966, '19650109', 'R. das Flores, 751, São Paulo, SP', 'M', 30000, 5);

But when I run the script I get this message:

ERROR:  value too long for type character varying(30)

The data type is set to DATE and I’ve also tried rewriting it in all sorts of ways, such as ‘1965-09-01’, ‘1965/09/01’, ‘1965.09.01’, and so on. I have even tried to use to_date()

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What should I do to revert this situation?

>Solution :

it seems that your ‘endereco’ is most probably limited to 30 characters and you are trying to insert 33 characters in that column.

You can try shortening that text and see if this works. If yes, then you should maybe rethink the max size of that column in the table.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading