Fórum Update Tabela #387319

27/09/2010

0

Bom dia, a minha duvida é a seguinte: preciso executar varias vezes o comando update na minha tabela MOVUSU   update movusu set id_cidade =  1  where id_cidade = ' ACRELANDIA' 
update movusu set id_cidade =  2  where id_cidade = ' ASSIS BRASIL'    update movusu
set id_cidade =  3  where id_cidade = ' BRASILEIA'   Existe alguma forma de colocar tudo dentro do mesmo comando? Exemplo:   update movusu set id_cidade =  1  where id_cidade = ' ACRELANDIA' set id_cidade =  2  where id_cidade = ' ASSIS BRASIL' set id_cidade =  3  where id_cidade = ' BRASILEIA'  
Sérgio

Sérgio

Responder

Posts

27/09/2010

Eriley Barbosa

Utilizando o ibexpert, você pode criar um script executavel: update movusu set id_cidade =  1  where id_cidade = ' ACRELANDIA' ;
update movusu set id_cidade =  2  where id_cidade = ' ASSIS BRASIL' ;  update movusu
set id_cidade =  3  where id_cidade = ' BRASILEIA' ;
Responder

Gostei + 0

27/09/2010

Sérgio

Usando a opção TOOLS - SCRIPT EXECUTIVE não funcionou:     update movusu
set id_cidade =  1  where id_cidade = ' ACRELANDIA' ;
update movusu
set id_cidade =  2  where id_cidade = ' ASSIS BRASIL' ;
update movusu
set id_cidade =  3  where id_cidade = ' BRASILEIA'   Invalid token.
Dynamic SQL Error.
SQL error code = -104.
Token unknown - line 3, char 1.
update.
(se colocar ; no final acusa o mesmo erro)  
Responder

Gostei + 0

27/09/2010

Emerson Nascimento

tente:

update movusu set
  id_cidade = (case id_cidade
               when ' ACRELANDIA' then '1'
               when ' ASSIS BRASIL' then '2'
               when ' BRASILEIA' then '3'
               else id_cidade end)


Responder

Gostei + 0

27/09/2010

Sérgio

Ok Com esse comando funcionou, muito obrigado Emerson.    Como se chama esse metodo?
Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar