24 lines
731 B
MySQL
24 lines
731 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`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 ;
|