You are on page 1of 5

SQL>

SQL> @D:\2.AOT\DBMS LAB Exam\prime.sql


SP2-0310: unable to open file "D:\2.AOT\DBMS.sql"
SQL> DECLARE
2 --the upper limit and the lower limit are taken as user inputs.
3 low number(2);
4 high number(2);
5 n number(2);
6 m number(2);
7 c number(20);
8 BEGIN
9 dbms_output.put_line('Enter the lower and higher limit:');
10 low:=&low;
11 high:=&high;
12 --The main operation happens in this loop
13 for n IN low.. high
14 loop
15 c:=0;
16 for m IN 1.. n
17 loop
18 if mod(n, m)=0 then
19 c:=c+1;
20 end if;
21 end loop;
22 --the number of divisors for each number in the range is counted and then
checked.
23 if c<=2 then
24 dbms_output.put_line(n||'\n');
25 end if;
26 end loop;
27
28 END;
29 /
Enter value for low: 10 20
old 10: low:=&low;
new 10: low:=10 20;
Enter value for high: ,s
old 11: high:=&high;
new 11: high:=,s;
low:=10 20;
*
ERROR at line 10:
ORA-06550: line 10, column 12:
PLS-00103: Encountered the symbol "20" when expecting one of the following:
* & = - + ; < / > at in is mod remainder not rem
<an exponent (**)> <> or != or ~= >= <= <> and or like like2
like4 likec between || multiset member submultiset
The symbol "*" was substituted for "20" to continue.
ORA-06550: line 11, column 10:
PLS-00103: Encountered the symbol "," when expecting one of the following:
( - + case mod new not null <an identifier>
<a double-quoted delimited-identifier> <a bind variable>
continue avg count current exists max min prior sql

SQL> DECLARE
2 --the upper limit and the lower limit are taken as user inputs.
3 low number(2);
4 high number(2);
5 n number(2);
6 m number(2);
7 c number(20);
8 BEGIN
9 dbms_output.put_line('Enter the lower and higher limit:');
10 low:=&low;
11 high:=&high;
12 --The main operation happens in this loop
13 for n IN low.. high
14 loop
15 c:=0;
16 for m IN 1.. n
17 loop
18 if mod(n, m)=0 then
19 c:=c+1;
20 end if;
21 end loop;
22 --the number of divisors for each number in the range is counted and then
checked.
23 if c<=2 then
24 dbms_output.put_line(n||'\n');
25 end if;
26 end loop;
27
28 END;
29 /
Enter value for low: 10
old 10: low:=&low;
new 10: low:=10;
Enter value for high: 20
old 11: high:=&high;
new 11: high:=20;

PL/SQL procedure successfully completed.

SQL> set server output on;


SP2-0158: unknown SET option "server"
SQL> set serveroutput on;
SQL> DECLARE
2 --the upper limit and the lower limit are taken as user inputs.
3 low number(2);
4 high number(2);
5 n number(2);
6 m number(2);
7 c number(20);
8 BEGIN
9 dbms_output.put_line('Enter the lower and higher limit:');
10 low:=&low;
11 high:=&high;
12 --The main operation happens in this loop
13 for n IN low.. high
14 loop
15 c:=0;
16 for m IN 1.. n
17 loop
18 if mod(n, m)=0 then
19 c:=c+1;
20 end if;
21 end loop;
22 --the number of divisors for each number in the range is counted and then
checked.
23 if c<=2 then
24 dbms_output.put_line(n||'\n');
25 end if;
26 end loop;
27
28 END;
29 /
Enter value for low: 10
old 10: low:=&low;
new 10: low:=10;
Enter value for high: 20
old 11: high:=&high;
new 11: high:=20;
Enter the lower and higher limit:
11\n
13\n
17\n
19\n

PL/SQL procedure successfully completed.

SQL> DECLARE
2 low number(2);
3 high number(2);
4 n number(2);
5 m number(2);
6 c number(20);
7 BEGIN
8 dbms_output.put_line('Enter the lower and higher limit:');
9 low:=&low;
10 high:=&high;
11 for n IN low.. high
12 loop
13 c:=0;
14 for m IN 1.. n
15 loop
16 if mod(n, m)=0 then
17 c:=c+1;
18 end if;
19 end loop;
20
21 if c<=2 then
22 dbms_output.put_line(n||' ');
23 end if;
24 end loop;
25
26 END;
27 /
Enter value for low: 10
old 9: low:=&low;
new 9: low:=10;
Enter value for high: 20
old 10: high:=&high;
new 10: high:=20;
Enter the lower and higher limit:
11
13
17
19

PL/SQL procedure successfully completed.

SQL> select * from Employee;

ENAME SSN_NO DOB CITY SEX SALARY MANAGER_SSN D_NO


---------- ---------- --------- ------- ------ ---------- ----------- ----------
Amit 1 01-JAN-92 Howrah Male 30000 1
Aman 2 02-FEB-93 Kolkata Male 40000 1 5
Tanya 3 05-JUN-96 Bandel Female 50000 1 5
Swanmoy 4 06-JUL-98 Rishra Male 20000 1 1
Arup 5 11-JUN-99 Kolkata Male 50000 1 5
Aritra 6 12-MAR-94 Kolkata Male 40000 2
Sumana 7 11-AUG-95 Bandel Female 30000 6 2
Ishita 8 09-JUN-98 Howrah Female 30000 6 4

8 rows selected.

SQL> select * from Department1;

DNAME D_NUM MGR_SSN


---------- ---------- ----------
Accounts 1 1
Research 5 1
Sales 2 6
HR 4 6

SQL> select * from Works_On;

SSN_NUM PROJECT_NO HOURS


---------- ---------- ----------
1 1 10
2 1 15
2 2 16
3 1 14
5 3 20
4 3 19

6 rows selected.

SQL> DECLARE
2 low number(2);
3 high number(2);
4 n number(2);
5 m number(2);
6 c number(20);
7 BEGIN
8 dbms_output.put_line('Enter the lower and higher limit:');
9 low:=&low;
10 high:=&high;
11 for n IN low.. high
12 loop
13 c:=0;
14 for m IN 1.. n
15 loop
16 if mod(n, m)=0 then
17 c:=c+1;
18 end if;
19 end loop;
20
21 if c<=2 then
22 dbms_output.put_line(n||' ');
23 end if;
24 end loop;
25
26 END;
27 /
Enter value for low: 10
old 9: low:=&low;
new 9: low:=10;
Enter value for high: 20
old 10: high:=&high;
new 10: high:=20;
Enter the lower and higher limit:
11
13
17
19

PL/SQL procedure successfully completed.

SQL> spool off;

You might also like