0
I am working with a bunch of data (Postgres) on vestibular and I was looking to do an update joining two tables and using UPDATE CASE WHEN THEN. I was relating the two tables through their ids and used a field of each to create the table update condition with new values. NOTE: These values that would be added do not exist in the tables and I didn’t want to waste time in doing several separate updates or separate Inserts.
Follows the code:
-- UPDATE PARA ADIÇÃO DO ID SISTEMA VAGA FINAL PARA CANDIDATOS INDEFERIDOS NO TESTE DE APTIDÃO E PCD (MUSICA)
UPDATE sigconcursos.inscricao AS insc
SET id_vaga_final = id_vaga_segunda_opcao,
id_vaga_sistema_vagas_final CASE
WHEN id_vaga_segunda_opcao = 262 THEN id_vaga_sistema_vagas_final = 812 -- ID VAGA SEGUNDA OPÇÃO DETERMINA QUAL VAGA SEGUIR PCD
WHEN id_vaga_segunda_opcao = 270 THEN id_vaga_sistema_vagas_final = 835
WHEN id_vaga_segunda_opcao = 286 THEN id_vaga_sistema_vagas_final = 881
FROM sigconcursos.analise_inscricao AS aninsc
WHERE insc.id_inscricao = aninsc.id_inscricao AND insc.id_vaga = 284
AND insc.id_vaga_sistema_vagas = 875 AND aninsc.id_status = 3 AND insc.id_concurso = 16
The Error:
O campo id_vaga_sistema_vagas_final é um inteiro e a operação retorna um booleano.
Our bro, really I was doing very badly kkkk. Really why was always returning compatibility error. As I was working with several tasks, I just missed this detail. Thanks for the tip :)
– Eryck Araujo