ORA-06550: line 21, column 1:
PLS-00103: Encountered the symbol "ELSE" when expecting one of the following:
begin case declare end exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge <a single-quoted SQL string> pipe
ORA-06550: line 23, column 1:
PLS-00103: Encountered the symbol "END"
The source code is:
declare
A NUMBER;
B NUMBER;
C NUMBER;
BEGIN
A:=&A;
B:=0;
C:=1;
IF A<10 THEN
IF A<=5 THEN
FOR I IN 1..A
LOOP
B:=B+I;
END LOOP ;
INSERT INTO TEMP(VALUE,RESULT) VALUES(A,B); ELSE FOR I IN 1..A
LOOP
C:=C*I;
END LOOP ;
INSERT INTO TEMP(VALUE,RESULT) VALUES(A,C);
ELSE DBMS_OUTPUT.PUT_FILE('ENTER A VALID NUMBER'); END IF; END;
Requires Free Membership to View
IF A<=5 THEN
BEGIN
FOR I IN 1..A
LOOP
B:=B+I;
END LOOP ;
INSERT INTO TEMP(VALUE,RESULT) VALUES(A,B);
ELSE
BEGIN
FOR I IN 1..A
LOOP
C:=C*I;
END LOOP ;
INSERT INTO TEMP(VALUE,RESULT) VALUES(A,C);
END IF;
In the above code, if A<=5, then the FOR loop is executed and the INSERT statement is executed. Else, the next FOR loop and INSERT statement executed. I denote the end of the ELSE clause with the END IF command.
I'm not sure if this is your intended application logic, but it does illustrate the point.
This was first published in January 2007

Join the conversationComment
Share
Comments
Results
Contribute to the conversation