UPDATE field BIGINT[] from a SELECT

Asked

Viewed 65 times

0

I have an update to a field

permissao_ver

Being the same guy bigint[], field response : '{1,2,3,4,5,11,44,56,75,11}'

My Query

UPDATE callcenter.pausa  
SET permissao_ver = '{"(SELECT cod_grupo FROM crm.usuariosgrupos
                        WHERE habilitar = 1)"}'::bigint[] 
WHERE habilitado = 1 AND permissao_ver is null

I need to get the codes that select will return me from giving an update in this field bigint[] '{XX,XX,XX,X,XX,X}'

  • Is the cod_group field already an array (bigint[])? In update you want to simply replace one array with another or merge the existing value with the subselect result?

1 answer

1

Solved .

UPDATE callcenter.pausa  
SET permissao_ver = array(SELECT cod_grupo 
                          FROM crm.usuariosgrupos
                          WHERE habilitar = 1)
WHERE habilitado = 1 
AND permissao_ver is null

Browser other questions tagged

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