Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

IF-ELSEIF-ELSE PL/SQL Error

CentinulJun 4 2008 — edited Jun 5 2008
For the life of me I cannot figure out what I'm doing wrong in this IF-ELSEIF-ELSE block. I coded up a small test to illustrate and here are the results:
SQL> DECLARE
  2     pVariable       VARCHAR2(10) := 'TEST';
  3  BEGIN
  4     IF pVariable = 'BLAH' THEN
  5             DBMS_OUTPUT.PUT_LINE('BLAH');
  6     ELSEIF pVariable = 'TEST' THEN
  7             DBMS_OUTPUT.PUT_LINE('TEST');
  8     ELSE
  9             DBMS_OTPUT.PUT_LINE('UNKNOWN');
 10     END IF;
 11  END;
 12  /
        ELSEIF pVariable = 'TEST' THEN
               *
ERROR at line 6:
ORA-06550: line 6, column 9:
PLS-00103: Encountered the symbol "PVARIABLE" when expecting one of the following:
:= . ( @ % ;
ORA-06550: line 11, column 4:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
if
I have tried the following variation:
DECLARE
	pVariable	VARCHAR2(10) := 'TEST';
BEGIN
	IF (pVariable='BLAH') THEN
		DBMS_OUTPUT.PUT_LINE('BLAH');
	ELSEIF (pVariable='TEST') THEN
		DBMS_OUTPUT.PUT_LINE('TEST');
	ELSE
		DBMS_OTPUT.PUT_LINE('UNKNOWN');
	END IF;
END;
The DB is Oracle 10gR2 10.2.0.3.

I have tried on SQL*Plus versions 10.2.0.3 & 8.1.7.0 and received the same error.

The documentation I have been referencing is:

http://download.oracle.com/docs/cd/B14117_01/appdev.101/b10807/04_struc.htm#sthref453
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 3 2008
Added on Jun 4 2008
9 comments
50,016 views