Postgre Insert null in char(3) does not work

Asked

Viewed 36 times

1

Below the error and the code I’m running Has two fields of this table that are defined as char(3), the field uf and the countryside ufcrm.

Does anyone know how I can do this insert?

SQL error:

ERROR: value Too long for type Character(3)

On the block:

INSERT INTO medico (crm,nome_med,fone1,fone2,fone3,celular,email,abrev,ufcrm,endereco,bairro,cep,cidade,uf,interno,senha,enviawww,padrao,chavesline,uncp_bak,unimed,uncp,status,cpf,espmed_id,datanasc,bpacns,bpacbo,login,obs_med,idopera_ultacao) values ('SP1913','Fulvius Titanero','11942993020',NULL,NULL,NULL,NULL,NULL,NULL,'Rua Eunice Weaver',NULL,'03333060','Sao Paulo','Sao Paulo',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1) RETURNING id

Thank you very much, I will change the "Uf" and I will rotate again to see

Below are a few more bugs I was testing here

SQL error:

ERROR: syntax error at or near "Error" LINE 1: SQL error: On the block:

SQL error:

ERROR: value Too long for type Character(3) In the block: INSERT INTO medico (ufcrm,Uf) values ('1', '1') RETURNING id

ERROR: syntax error at or near "Error" LINE 1: SQL error: On the block:

SQL error:

ERROR: value Too long for type Character(3) In the block: INSERT INTO medico (ufcrm,Uf) values (', ') RETURNING id

OK OK OK> solved was the very size of Uf

thanks to everyone who helped

  • Uf is receiving "Sao Paulo" which has 9 characters, and only supports 3 characters. In this case, you have to denifir if São Paulo will be 'SP' or you will have to increase the field capacity for more characters. ufcms is the same thing, is inserting 'NULL' that has 4 characters, in a field that only accepts 3 characters

1 answer

1


Uf is receiving "Sao Paulo" that have 9 characters, whereas only supports 3 characters. In this case, you have to define whether "Sao Paulo" will be 'SP'(only the state acronym) or will have to increase the field capacity for more characters (Ex: "Rio Grande do Norte" is the Brazilian state with the highest name and has 19 characters, this would have to be the maximum capacity of this field). The ufcms is the same thing, is inserting 'NULL' that has 4 characters, in a field that only accepts 3 characters.

  • 1

    thanks a lot, I was with the head and other things and I didn’t stay tuned with the basics, thanks @Edward Ramos

Browser other questions tagged

You are not signed in. Login or sign up in order to post.