Compilation error with simple ELSIF [message #447268] |
Fri, 12 March 2010 16:37  |
dbmeany
Messages: 11 Registered: January 2010
|
Junior Member |
|
|
what I don't get is what is wrong with my ELSIF statement?
-- Majic program that will guess how much you are worth
ACCEPT s_first PROMPT 'Enter your random letter'
DECLARE
random_letter VARCHAR(20);
personal_worth VARCHAR(20);
BEGIN
IF random_letter >= 'A' AND <= 'D' THEN
personal_worth = '$100,000';
ELSIF random_letter >= 'E' AND <= 'K' THEN
personal_worth = '$10,000';
ELSIF random_letter >= 'L' AND <= 'N' THEN
personal_worth = '$1,000';
ELSIF random_letter >= 'O' AND <= 'P' THEN
personal_worth = '$100';
ELSIF random_letter >= 'Q' AND <= 'T' THEN
personal_worth = '$10';
ELSE random_letter >= 'U' AND <= 'Z' THEN
personal_worth = '$1';
dbms_output.put_line('The letter you entered was ' || random_letter || ' and your personal worth is ' || personal_worth);
END;
|
|
|
|
|
|
|
Re: Compilation error with simple ELSIF [message #447846 is a reply to message #447268] |
Thu, 18 March 2010 04:01   |
s4.ora
Messages: 71 Registered: March 2010
|
Member |
|
|
There is a missing END IF statement in the Block. The condition is also incorrect.
Try this out, i have used a BETWEEN operator instead.
set serverout on
DECLARE
random_letter VARCHAR(20):='E';
personal_worth VARCHAR(20);
BEGIN
IF random_letter between 'A' AND 'D' THEN
personal_worth:='$100,000';
ELSIF random_letter between 'E' AND 'K' THEN
personal_worth:='$10,000';
ELSIF random_letter between 'L' AND 'N' THEN
personal_worth:='$1,000';
ELSIF random_letter between 'O' AND 'P' THEN
personal_worth:='$100';
ELSIF random_letter between 'Q' AND 'T' THEN
personal_worth:='$10';
ELSIF random_letter between 'U' AND 'Z' THEN
personal_worth:='$1';
END IF;
dbms_output.put_line('The letter you entered was ' || random_letter || ' and your personal worth is ' || personal_worth);
END;
/
|
|
|
|