MySQL Forums
Forum List  »  Portuguese

Insert Condicional
Posted by: Carlos Junior
Date: September 22, 2008 07:28AM

Olá a todos,

existe uma maneira de fazer algo assim, estava tentando fazer uma jogada de insert condicional mas ele retorna erro de sintaxe, sei que está errado mas antes de dar soco em ponta de faca vim pedir alguma ajuda aqui.

Aqui segue o que eu estava tentando fazer.

if exists (select c.id_cliente from cliente c where c.nome = 'Carlos') then
update cliente set nome = 'Carlos A.' where id_cliente = '1';
else
insert into cliente(nome) values('Carlos Novo');
end

Agradeço qualquer ajuda. Abraços.

Options: ReplyQuote


Subject
Views
Written By
Posted
Insert Condicional
7458
September 22, 2008 07:28AM
3788
October 07, 2008 10:29AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.