29 lines
823 B
MySQL
29 lines
823 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`observationAdd`(vOriginFk INT, vTableCode VARCHAR(45), vDescription TEXT)
|
||
|
BEGIN
|
||
|
/**
|
||
|
* Guarda las observaciones realizadas por el usuario
|
||
|
*
|
||
|
* @param vOriginFk Id del registro de origen
|
||
|
* @param vTypeCode Código que referencia a la tabla.
|
||
|
* @param descripcion Texto de la observacion
|
||
|
*/
|
||
|
DECLARE vTableName VARCHAR(45);
|
||
|
|
||
|
SET vTableName = CONCAT(vTableCode,'Observation');
|
||
|
|
||
|
IF ISNULL(vTableName) THEN
|
||
|
CALL util.throw('CODE_NOT_FOUND');
|
||
|
END IF;
|
||
|
|
||
|
SET @qryLog := CONCAT(
|
||
|
'INSERT INTO ', vTableName, ' (originFk, userFk, description)',
|
||
|
' VALUES (', vOriginFk, ', ', account.myUser_getId(), ', "', vDescription, '")'
|
||
|
);
|
||
|
|
||
|
PREPARE stmt FROM @qryLog;
|
||
|
EXECUTE stmt;
|
||
|
DEALLOCATE PREPARE stmt;
|
||
|
END$$
|
||
|
DELIMITER ;
|