Reputation: 458
I was writing a simple program of senior citizen checking. But the error baffled me. The code as follows
declare
gen char(1);
age number(3);
begin
gen:='&gen';
age:=&age;
if age>65 and gen='m'
then
dbms_output.put_line("senior citizen");
elsif age>60 and gen='f'
then
dbms_output.put_line("senior citizen");
else
dbms_output.put_line(" not a senior citizen");
endif;
end;
error at line 20:
ora 06550:line 20, column 4
pls-00103:encountered symbol ';' when expecting one of the following if
I really don't know what is wrong
Upvotes: 1
Views: 4071
Reputation: 11
declare
gen char(1) := lower(:Gender) ;
age number(3) := :Age;
begin
if (
(age>65 and gen = 'm') OR (age>60 and gen ='f')
)then
dbms_output.put_line('senior citizen');
else
dbms_output.put_line(' not a senior citizen');
end if;
end;
Upvotes: 0
Reputation: 7284
declare
gen char(1);
age number(3);
begin
gen:='&gen';
age:=&age;
if age>65 and gen='m'
then
dbms_output.put_line('senior citizen');
elsif age>60 and gen='f'
then
dbms_output.put_line('senior citizen');
else
dbms_output.put_line(' not a senior citizen');
end if;
end;
You have to use '
instade of "
to show string messages when using dbms_output.put_line
Also there was an endif
,that must be replace with end if
Hope be helpful pal.
Upvotes: 3
Reputation: 50017
It should be "end if;", not "endif;".
(And yes, this is somewhat inconsistent with "elsif". Funny old thing, syntax... :-)
Share and enjoy.
Upvotes: 1