Error in following PL\SQl Statment

All posts relating to Oracle PL/SQL development.

Moderator: Tim...

Error in following PL\SQl Statment

Postby suresh661 » Sun Nov 11, 2012 3:45 pm

Hi All,

I'm new to Oracle , if facing syntax error in the following statement (ELS IF). i tried it to my extent . i would be a great help if some one corrects me

Thanks in Advance



Code: Select all

Declare
V_Number1 Number;
V_Number2 Number;
V_Result Varchar2(7);


Begin

If V_Number1 Is Null Or V_Number 2 Is Null Then
 V_RESULT:= 'UnKnown';
   
    ELSE If V_Number1 < V_Number2 Then
    V_Result:='Yes';
    Else
    V_Result :='No';
    End If;
   
DBMS_OUTPUT.PUT_LINE(V_Result);

END;
suresh661
Member
 
Posts: 2
Joined: Sun Nov 11, 2012 3:39 pm

Re: Error in following PL\SQl Statment

Postby Tim... » Mon Nov 12, 2012 9:31 am

Hi.

ELSIF, not ELSE IF.

Code: Select all
DECLARE
  v_number1 NUMBER;
  v_number2 NUMBER;
  v_result  VARCHAR2(7);
BEGIN

  IF v_number1 IS NULL OR v_number2 IS NULL THEN
    v_result := 'UnKnown';
     
  ELSIf v_number1 < v_number2 THEN
    v_result := 'Yes';
  ELSE
    v_result := 'No';
  END IF;
   
  DBMS_OUTPUT.PUT_LINE(v_result);

END;
/


Cheers

Tim...
Tim...
Oracle ACE Director
Oracle ACE of the Year 2006 - Oracle Magazine Editors Choice Awards
OakTable Member
OCP DBA 7.3, 8, 8i, 9i, 10g, 11g
OCP Advanced PL/SQL Developer
Oracle Database: SQL Certified Expert
My website: http://www.oracle-base.com
My blog: http://www.oracle-base.com/blog
Tim...
Site Admin
 
Posts: 17937
Joined: Mon Nov 01, 2004 5:56 pm
Location: England, UK

Re: Error in following PL\SQl Statment

Postby suresh661 » Mon Nov 12, 2012 6:20 pm

thank you very much Tim.
suresh661
Member
 
Posts: 2
Joined: Sun Nov 11, 2012 3:39 pm

Re: Error in following PL\SQl Statment

Postby Tim... » Mon Nov 12, 2012 6:41 pm

:)
Tim...
Oracle ACE Director
Oracle ACE of the Year 2006 - Oracle Magazine Editors Choice Awards
OakTable Member
OCP DBA 7.3, 8, 8i, 9i, 10g, 11g
OCP Advanced PL/SQL Developer
Oracle Database: SQL Certified Expert
My website: http://www.oracle-base.com
My blog: http://www.oracle-base.com/blog
Tim...
Site Admin
 
Posts: 17937
Joined: Mon Nov 01, 2004 5:56 pm
Location: England, UK


Return to Oracle SQL and PL/SQL Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron