Update Tabela
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'
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
Curtidas 0
Respostas
Eriley Barbosa
27/09/2010
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' ;
update movusu set id_cidade = 2 where id_cidade = ' ASSIS BRASIL' ; update movusu
set id_cidade = 3 where id_cidade = ' BRASILEIA' ;
GOSTEI 0
Sérgio
27/09/2010
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)
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)
GOSTEI 0
Emerson Nascimento
27/09/2010
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)
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)
GOSTEI 0
Sérgio
27/09/2010
Ok Com esse comando funcionou, muito obrigado Emerson.
Como se chama esse metodo?
GOSTEI 0