MySQL Forums
Forum List  »  Stored Procedures

Error trying to create Store Procedure
Posted by: Jeison Friedman
Date: August 10, 2020 11:30AM

Hello community! I hope you can help me.

I've wasted a lot of time trying to know what I'm doing wrong, but I can't figure it out. This is my code:

DELIMITER //
CREATE PROCEDURE append_domicilio(
IN clave_empresa_in VARCHAR(32),
IN id_mesa_in TINYINT(2) UNSIGNED,
IN id_persona_in SMALLINT(5) UNSIGNED,
IN id_direccion_in SMALLINT(5) UNSIGNED)
begin
-- Variables
declare id_empresa_var SMALLINT(4);
-- Valido
if not exists (
select *
from empresas e
where e.clave = clave_empresa_in)
then
call throw_error('La clave de empresa indicada no existe en el registro');
-- Asigno valor
select e.id
into id_empresa_var
from empresas e
where e.clave = clave_empresa_in;
-- Inserto datos
insert into domicilios(
id_empresa,
id_mesa,
id_persona,
id_direccion)
values (
id_empresa_var,
id_mesa_in,
id_persona_in,
id_direccion_in);
end//

When a run this in PhpMyAdmin, it raise #1064 error pointing to the last line. Any ideas?

Options: ReplyQuote


Subject
Views
Written By
Posted
Error trying to create Store Procedure
262
August 10, 2020 11:30AM


Sorry, only registered users may post in this forum.

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.