找不到程序失败的地方

时间:2018-11-10 17:50:15

标签: mysql

我花了一个小时查看代码,但是找不到失败的地方

    DELIMITER $$
    DROP PROCEDURE IF EXISTS equipos$$
    CREATE PROCEDURE equipos(IN nom varchar, IN loc varchar, IN usu varchar
, IN pass varchar, OUT mensaje varchar, OUT nombreOut varchar)
    BEGIN
    select @var:=count(*) from usuario where usu=usuario.usuario;
    if(@var=0) THEN
        INSERT INTO `usuario`(`usuario`, `contraseña`) VALUES (usu,MD5(pass));
        select @id:=usuario.idUsuario from usuario WHERE usuario.usuario=usu;
        INSERT INTO `equipo`(`nombre`, `localidad`, `idUsuario`) VALUES (nom,loc,@id);
        SET mensaje="";
        Set nombreOut=nom;
    else
    SET mensaje="ya existe ese usuario";
    END IF;
    END$$

    DELIMITER ;

给我这个错误

something mistaken in your sintax near ' IN loc varchar, IN usu varchar, IN pass varchar, OUT mensaje varchar, OUT nombr' in line 1

2 个答案:

答案 0 :(得分:0)

在声明varchar时,必须指定其最大长度。喜欢

<!DOCTYPE html>
<html>
<body>
<div id="main-row" class="et_pb_row et_pb_row_0 main-row et_pb_row_4col">
				<div class="et_pb_column et_pb_column_1_4 et_pb_column_0    et_pb_css_mix_blend_mode_passthrough">
				
				
				<div class="et_pb_module et_pb_text et_pb_text_0 column-1 et_hover_enabled et_pb_bg_layout_light  et_pb_text_align_left">
				
				
				
			</div> <!-- .et_pb_text -->
      <div class="wrapper-background"></div>
      <div class="et_pb_module et_pb_text et_pb_text_1 column-2 et_hover_enabled et_pb_bg_layout_light  et_pb_text_align_left">
	
				
			</div>
      <div class="wrapper-background"></div>
			</div> <!-- .et_pb_column --><div class="et_pb_column et_pb_column_1_4 et_pb_column_1    et_pb_css_mix_blend_mode_passthrough">
				
				
				<div class="et_pb_module et_pb_text et_pb_text_2 column-3 et_hover_enabled et_pb_bg_layout_light  et_pb_text_align_left">
				
			</div> 
      <div class="wrapper-background"></div>
      <div class="et_pb_module et_pb_text et_pb_text_3 column-4 et_hover_enabled et_pb_bg_layout_light  et_pb_text_align_left">

			</div>
      <div class="wrapper-background"></div>
			</div> <!-- .et_pb_column -->
      <div class="et_pb_column et_pb_column_1_4 et_pb_column_2    et_pb_css_mix_blend_mode_passthrough">
				
				
				<div class="et_pb_module et_pb_text et_pb_text_4 column-5 et_hover_enabled et_pb_bg_layout_light  et_pb_text_align_left">
				
				
				
			</div>
      <div class="wrapper-background"></div>
      <div class="et_pb_module et_pb_text et_pb_text_5 column-6 et_hover_enabled et_pb_bg_layout_light  et_pb_text_align_left">
				
				
				
			</div>
      <div class="wrapper-background"></div>
			</div> <!-- .et_pb_column --><div class="et_pb_column et_pb_column_1_4 et_pb_column_3    et_pb_css_mix_blend_mode_passthrough et-last-child">
				
				
				<div class="et_pb_module et_pb_text et_pb_text_6 column-7 et_hover_enabled et_pb_bg_layout_light  et_pb_text_align_left">
				
			</div>
      <div class="wrapper-background"></div>
      <div class="et_pb_module et_pb_text et_pb_text_7 column-8 et_hover_enabled et_pb_bg_layout_light  et_pb_text_align_left">
				
				
				
			</div>
      <div class="wrapper-background"></div>
			</div> <!-- .et_pb_column -->
				
				
			</div>
</div>
</body>
</html>

答案 1 :(得分:0)

在提及VARCHAR数据类型时,您需要指定变量的最大长度

CREATE PROCEDURE equipos(IN nom varchar(64), ...