General Question

yankeetooter's avatar

I understand what the PL/SQL code below is supposed to do, but when I run the code, it won't compile. Can anybody help with why this is so?

Asked by yankeetooter (9651points) September 25th, 2013

DECLARE
CREATE TABLE Ten_Multiples
( Numbervalue number(3));
BEGIN
FOR i IN 9 .. 101 LOOP
IF (i = 50 OR i = 90) THEN
ELSIF (i%10 = 0) THEN
insert into Ten_Multiples
VALUE (i);
END IF;
END LOOP;
END;

I get that the above code should enter the following values into the table: 10, 20, 30, 40, 60, 70, 80, 100. I just can’t understand why it won’t compile. (The code is not mine…the professor posted it and asked us to tell what the outcome will be. I wanted to test it to check my answer, but it’s giving me issues. The problem lies in the line ELSIF i%10 = 0 THEN.

Observing members: 0 Composing members: 0

4 Answers

funkdaddy's avatar

PL\SQL really isn’t my thing, but I believe you need something between the first IF statement and the ELSIF.

What do you want it to do with the number if it is 50 or 90?

yankeetooter's avatar

I figured out that I needed to at least put a NULL statement after the first THEN. Again, it’s not my code, but my professor’s, and I can only assume he doesn’t want those two values added to the table.

dabbler's avatar

Or change the ELSIF into an IF…?

yankeetooter's avatar

I wondered about that, but since that part doesn’t necessarily keep the code from running, I didn’t want to change that.

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther