salix/db/routines/vn/procedures/logShow.sql

24 lines
729 B
MySQL
Raw Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`logShow`(vOriginFk INT, vEntity VARCHAR(45))
BEGIN
/**
* Muestra las acciones realizadas por el usuario
*
* @param vOriginFk Id del registro de origen
* @param vEntity Nombre que hace referencia a la tabla.
*/
DECLARE vTableName VARCHAR(45);
SET vTableName = CONCAT(vEntity, 'Log');
SET @qryLog := CONCAT(
'SELECT ot.id, ot.originFk, ot.userFk, u.name, ot.action, ot.creationDate, ot.description FROM ', vTableName, ' AS ot',
' INNER JOIN account.user u ON u.id = ot.userFk',
' WHERE ot.originFk = ', vOriginFk, ' ORDER BY ot.creationDate DESC'
);
PREPARE stmt FROM @qryLog;
EXECUTE stmt;
END$$
DELIMITER ;