PL SQL LOOP 逻辑 if else if
Posted
技术标签:
【中文标题】PL SQL LOOP 逻辑 if else if【英文标题】:PL SQL LOOP logic if else if 【发布时间】:2015-12-16 01:30:44 【问题描述】:判断语句有错误
错误:PLS-00103:符号“ELSE” (开始案例声明结束 退出 goto if loop mod null pragma raise return select 同时更新
FETCH date_time into r_pernr,r_aedtm,r_tprog,r_nobeg,r_noend,r_sollz,r_pabeg,r_paend,r_pdunb;
IF l_time_s < r_nobeg THEN
raise e_req_hour_error2;
ELSE IF l_time_e > r_noend THEN
raise e_req_hour_error3;
ELSE IF l_time_e IS NULL AND l_time_s IS NULL THEN
l_time := r_sollz;
ELSE IF l_time_s IS NOT NULL AND l_time_e IS NULL THEN
IF l_time_s >= r_nobeg AND l_time_s <= r_pabeg THEN
l_time := r_pabeg - l_time_s + ( r_noend - r_paend );
ELSE IF l_time_s >= r_paend AND l_time_s <= r_noend THEN
l_time := r_noend - l_time_s;
ELSE IF l_time_s > r_pabeg AND l_time_s < r_paend THEN
l_time := r_noend - r_paend;
END IF;
ELSE IF l_time_s IS NULL AND l_time_e IS NOT NULL THEN
IF l_time_e <= r_pabeg THEN
l_time := l_time_e - r_pabeg;
ELSE IF l_time_e <= r_noend AND l_time_e >= r_nobeg THEN
l_time := r_noend - r_paend;
ELSE IF l_time_e >= r_paend AND l_time_e <= r_noend THEN
l_time := r_pabeg - r_nobeg + ( l_time_e - r_paend );
END IF;
ELSE IF l_time_s IS NOT NULL AND l_time_e IS NOT NULL THEN
IF l_time_s >= r_nobeg AND l_time_e <= r_pabeg THEN
l_time := l_time_e - l_time_s;
ELSE IF l_time_s >= r_nobeg AND l_time_e >= r_pabeg AND l_time_e <= r_paend THEN
l_time := r_pabeg - l_time_s;
ELSE IF l_time_s >= r_pabeg AND l_time_e <= r_noend THEN
l_time := l_time_e - r_paend;
ELSE IF l_time_s >= r_paend AND l_time_e <= r_noend THEN
l_time := l_time_e - l_time_s;
END IF;
IF l_time = 0 THEN
raise e_req_hour_error4;
END IF;
END IF;
【问题讨论】:
【参考方案1】:语法错误是因为在Oracle中if else应该是如下所示的格式。
IF condition1 THEN
...statements to execute when condition1 is TRUE...
ELSIF condition2 THEN
...statements to execute when condition2 is TRUE...
ELSE
...statements to execute when both condition1 and condition2 are FALSE...
END IF;
【讨论】:
以上是关于PL SQL LOOP 逻辑 if else if的主要内容,如果未能解决你的问题,请参考以下文章