DROP PROCEDURE IF EXISTS raise;
CREATE PROCEDURE raise(@uld int)
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
SET @uld = (select ULD_ID from doctor_personal_details)
IF(@uld = NULL) THEN
SET MESSAGE_TEXT = ' error occurred';
END;
我在ULD_ID
中有doctor_personal_details
列,当ULD_ID
中没有数据时,我需要显示错误消息。
答案 0 :(得分:0)
您需要做的是检查是否存在提供uld
和SIGNAL
错误的记录,如果没有,例如:
BEGIN
DECLARE CNT INT;
SELECT COUNT(*) INTO CNT
FROM doctor_personal_details
WHERE ULD_ID = uld;
IF(C = 0) THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'No records exist with given uid';
ELSE
SELECT 'Success' AS message;
END IF;
END
答案 1 :(得分:0)
DROP PROCEDURE IF EXISTS raise1;
CREATE PROCEDURE raise1
(IN uld int)
BEGIN
DECLARE CNT INT;
DECLARE MESSAGE_TEXT varchar(80);
SELECT COUNT(*)INTO CNT
FROM doctor_personal_details
在哪里ULD_ID = uld;
IF(CNT = 0)那么
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'No records exist with given uid'; ELSE
选择'成功' AS消息;
END IF;
END;
致电raise1(' 3');