Help in SQL statement to update

2

I was creating a procedure but I came across an error in doing it.

create procedure actualizar (in id int, in nom varchar(45), in corr 
varchar(45))
begin
update dpersona set nombre=nom, correo=corr where idpersona=id;
end

In the part of 'id'me send Syntax error: Missing' semicolon '

    
asked by Estefania 07.05.2017 в 21:11
source

1 answer

1

The error may be due to what MySQL says in the documentation:

  

If you use the mysql client program to define a program   stored that contains semicolons, a problem arises.   By default, mysql recognizes the semicolon as a   delimiter of instructions, so you must redefine the delimiter   temporarily so that mysql passes all the definition of the program   stored to the server.

     

To redefine the mysql delimiter, use the DELIMITER command. The   delimiter is changed to // to allow the entire definition to be   passed to the server as a single statement and then restored to ;   before invoking the procedure. This activates the delimiter ;   used in the body of the procedure to be passed through the   server instead of being interpreted by the mysql itself.

     

▸ Source: MySQL Reference Manual, 23.1 Defining Stored   Programs

Example:

delimiter //
create procedure actualizar 
    (in id int, in nom varchar(45), in corr varchar(45))
begin
    update dpersona set nombre=nom, correo=corr where idpersona=id;
end
//
delimiter ;
    
answered by 07.05.2017 / 21:46
source