begin if work_start FROM work where work_start=CONCAT(DATE_FORMAT(r_time, '%W%H:%i')) then insert into reserve(New.r_id,p_id,d_id,r_time,'已预约',null); else SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Data does not meet the requirements'; end if; end有错
时间: 2024-03-27 20:39:14 浏览: 122
解决Oracle没有WM_CONCAT函数.zip
这段代码中的错误在于缺少了一个关键字 `SELECT`,导致无法正确从 `work` 表中获取到工作开始时间。正确的代码应该是:
```
BEGIN
IF (SELECT work_start FROM work WHERE work_start = CONCAT(DATE_FORMAT(r_time, '%W%H:%i'))) THEN
INSERT INTO reserve (New.r_id, p_id, d_id, r_time, status, note) VALUES (New.r_id, New.p_id, New.d_id, New.r_time, '已预约', null);
ELSE
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Data does not meet the requirements';
END IF;
END;
```
这样修改后,代码应该就可以正常执行了。
阅读全文