SQL*Plus: Release 10.2.0.1.
0 - Production on Wed Sep 18 15:46:36 2024
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> connect system
Enter password:
Connected.
SQL> set serveroutput on
SQL> declare
2 a number(2):=10;
3 begin
4 a:=10;
5 if (a<20) then
6 dbms_output.put_line('a is less than 20');
7 end if;
8 dbms_output.put_line('value of a is: ' || a);
9 end;
10 /
a is less than 20
value of a is: 10
PL/SQL procedure successfully completed.
SQL> declare
2 a number(3):=100;
3 begin
4 if (a<20) then
5 dbms_output.put_line('a is less than 20');
6 else
7 dbms_output.put_line('a is not less than 20');
8 end if;
9 dbms_output.put_line('value of a is:' || a);
10 end;
11 /
a is not less than 20
value of a is:100
PL/SQL procedure successfully completed.
SQL> DECLARE
2 a number(3) := 100;
3 BEGIN
4 IF ( a = 10 ) THEN
5 dbms_output.put_line('Value of a is 10' );
6 ELSIF ( a = 20 ) THEN
7 dbms_output.put_line('Value of a is 20' );
8 ELSIF ( a = 30 ) THEN
9 dbms_output.put_line('Value of a is 30' );
10 ELSE
11 dbms_output.put_line('None of the values is matching');
12 END IF;
13 dbms_output.put_line('Exact value of a is: '|| a );
14 END;
15 /
None of the values is matching
Exact value of a is: 100
PL/SQL procedure successfully completed.
SQL> DECLARE
2 i number(3);
3 j number(3);
4 BEGIN
5 i := 2;
6 LOOP
7 j:= 2;
8 LOOP
9 exit WHEN ((mod(i, j) = 0) or (j = i));
10 j := j +1;
11 END LOOP;
12 IF (j = i ) THEN
13 dbms_output.put_line(i || ' is prime');
14 END IF;
15 i := i + 1;
16 exit WHEN i = 50;
17 END LOOP;
18 END;
19 /
2 is prime
3 is prime
5 is prime
7 is prime
11 is prime
13 is prime
17 is prime
19 is prime
23 is prime
29 is prime
31 is prime
37 is prime
41 is prime
43 is prime
47 is prime
PL/SQL procedure successfully completed.
SQL>