Pessoal estou precisando efetuar um update de uma tabela fazendo um select com join em outra tabela. O problema e o seguinte
preciso colocar GNA ou Outros no campo criadas_group_master
da tabela tbl_os_siebel caso o usuario desta linha da tabela criado_por seja igual ao f.username da tabela us_adm.tbl_funcionarios f se isso for verdade coloco GNA se nao coloco Outros, porem nao esta funcionando, alguem pode ajudar ai
segue o SQL abaixo
update tbl_os_siebel t set
t.criadas_group_master=
(select case when src.username is null then ‘Outros’ Else ‘GNA’end as REFMASTER
from
(select r.numero_da_os, f.username
from us_adm.tbl_funcionarios f, tbl_os_siebel r
where r.criado_por=f.username(+)
and r.aberto_em>=to_date(’12/07/2010′,’DD/MM/YYYY’)) src
where t.numero_da_os = src.numero_da_os
and t.criadas_group_master is null)
where exists
(select case when src.username is null then ‘Outros’ Else ‘GNA’end as REFMASTER
from
(select r.numero_da_os, f.username
from us_adm.tbl_funcionarios f, tbl_os_siebel r
where r.criado_por=f.username(+)
and r.aberto_em>=to_date(’12/07/2010′,’DD/MM/YYYY’)) src
where t.numero_da_os = src.numero_da_os
and t.criadas_group_master is null)