Accept Number1 Prompt '1st Number: '
Accept Number2 Prompt '2nd Number: '
Declare
Var1 Number := &Number1 ;
Var2 Number := &Number2 ;
Begin
Case True
When (Var1 > Var2)
Then Dbms_Output.Put_Line('1st > 2nd');
When (Var1 < Var2)
Then Dbms_Output.Put_Line('1st < 2nd');
Else Dbms_Output.Put_Line('1st = 2nd');
End Case;
End;
/
Enter value for number1: NULL
ReplyDeleteold 2: Var1 Number := &Number1 ;
new 2: Var1 Number := null ;
Enter value for number2: 2
old 3: Var2 Number := &Number2 ;
new 3: Var2 Number := 2 ;
1st = 2nd
One of my favorite uses for CASE:
CASE x WHEN x THEN 'not null' ELSE 'null' END