[英]multiple/nested begin/end, function statements in procedures in pl/sql
[英]PL/SQL nested IF statements
运行代码后,我遇到了很多错误。 该问题要求显示为余额 > 100 的人提供的折扣,如果该人拥有名为 BCBS 的保险,他/她将获得 10% 的折扣。 如果他/她有名为 SIH 的保险,他/她将获得 20% 的折扣。 对于余额> 100但未参加上述两种保险的人,他/她将获得5%的折扣。 对于余额<100的人,他们需要按原样支付余额。 该问题还要求患者写下他/她的患者 ID。
accept ptid prompt 'Enter your patieint ID:'
begin
declare
pt_id number;
balance number;
pt_ins varchar2 (11);
amount number;
pt_id := &ptid;
select balance,pt_ins from billing;
if
balance < 100;
begin
dbms_output.put_line('You need to pay RM '||balance);
end;
else
begin
if pt_ins = 'BCBS'
begin
amount := 0.9 * balance;
dbms_output.put_line('You need to pay RM '||amount);
end;
elsif pt_ins := 'SIH'
begin
amount := 0.8 * balance;
dbms_output.put_line('You need to pay RM '||amount);
end;
else
begin
amount := 0.95 * balance;
dbms_output.put_line('You need to pay RM '||amount);
end;
end;
end;
您必须使用 'then': if (balance<100) then dbms_output...
条件后面不应该有分号 您过去需要在条件周围加上括号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.