MySQL Forums
Forum List  »  Portuguese

execução estranha
Posted by: Lucas Michel
Date: July 22, 2008 08:13AM

criei uma function que esta tendo uma execução estranha:

DELIMITER $$

DROP FUNCTION IF EXISTS `cse_2008`.`TESTA_EXISTENCIA_USER` $$
CREATE DEFINER=`root`@`localhost` FUNCTION `TESTA_EXISTENCIA_USER`(NOME_USUARIO VARCHAR(100)) RETURNS int(11)
begin

declare flag, PARTE_TEXTO varchar(100);
declare numero int;

DECLARE CONTINUE HANDLER FOR SQLSTATE '02000'

SET PARTE_TEXTO = CONCAT('"',NOME_USUARIO,'"');

select login_user into flag from view_usuario WHERE login_user = NOME_USUARIO;

if flag is null then
set numero = 0;
else
set numero = 1;
end if;

return numero;


END $$

DELIMITER ;

se vc observarem esta function retorna se achou ou não o usuario só que pra ela executar corretamente eu não posso excluir ou comentar esta linha:
SET PARTE_TEXTO = CONCAT('"',NOME_USUARIO,'"');

eu coloquei esta linha pra testar a questão das aspas que as vezes é necessário só que não utilizo mas esta variavel PARTE_TEXTO uso a variavel de entrada sem concatenar e executa corretamente só que se for excluida ou comentada retorna os valores errado o que vc acham?

Options: ReplyQuote


Subject
Views
Written By
Posted
execução estranha
4036
July 22, 2008 08:13AM


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.