Documente Academic
Documente Profesional
Documente Cultură
source mysql/procs5.sql
set @f=0;
call numero_filas(@f);
select @f;
+------+
| @f |
+------+
| 11 |
+------+
11 filas tiene la tabla mascotas
Ahora meteremos un parmetro
drop procedure if exists numero_filas;
delimiter //
create procedure numero_filas(in tabla varchar(10), out filas int)
begin
if tabla='mascotas' then
select count(*) into filas from mascotas;
else
select count(*) into filas from mascotas;
end if;
end//
delimiter ;
else
select * from mascotas limit 10;
end if;
select count(*) into @a from mascotas;
set filas=@a-filas;
end//
delimiter ;
begin
declare numNombres, numApellido smallint;
select nomReg('nombres') into numNombres;
select numReg('apellido') into numApellido
if numero > 0 then
set @a=0;
else
select 'El parmetro de entrada tiene que ser positivo distinto de 0' as
'mensaje de error';
end if;
end//
delimiter ;
end//
delimiter ;