0
이 뭔가 아주 기본적인,하지만 난 그것을 이해할 수없는, 그리고 매뉴얼은 도움이되지 않습니다RAISEERROR 문을 사용하는 방법?
declare @rule int =
(select id from menu_availability_rules
where (daily_serving_start = null or
(daily_serving_start is null and null is null)) and
(daily_serving_end = null or
(daily_serving_end is null and null is null)) and
(weekly_service_off = 3 or
(weekly_service_off is null and 3 is null)) and
(one_time_service_off = null or
(one_time_service_off is null and null is null)));
print @rule;
-- syntax error here --\/
if (@rule is not null) raiseerror ('test error', 42, 42);
if @rule is not null
begin
delete from menu_availability
where menu_id = 5365 and rule_id = @rule
delete from menu_availability_rules
where (daily_serving_start = null or
(daily_serving_start is null and null is null)) and
(daily_serving_end = null or
(daily_serving_end is null and null is null)) and
(weekly_service_off = 3 or
(weekly_service_off is null and 3 is null)) and
(one_time_service_off = null or
(one_time_service_off is null and null is null))
and not exists
(select rule_id from menu_availability
where rule_id = @rule)
end
이 왜 구문 오류인가? 나는 그것을 어떻게 쓸 것인가? 코드가 조건부 분기에 도달했는지 확인하기 위해 디버깅 목적으로 오류가 발생합니다.
raiseerror
을 select 1/0
으로 바꿀 수 있습니다. 필요한 것을 얻을 수는 있지만 정상적으로 할 수없는 이유는 무엇입니까?
어떤 이유로 명령의 철자가'raiseerror'가 아닌'raiserror'입니다. – Guffa