0% found this document useful (0 votes)
0 views

Python Notes

The document contains a series of PL/SQL code examples for an assignment in a BSC.IT course. It includes tasks such as displaying 'HELLO WORLD!', declaring variables, creating user-defined records, using conditional statements (IF, CASE), and checking employee statuses based on salary and experience. Each task is presented with input and expected output, attributed to different students.

Uploaded by

Dipak Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Python Notes

The document contains a series of PL/SQL code examples for an assignment in a BSC.IT course. It includes tasks such as displaying 'HELLO WORLD!', declaring variables, creating user-defined records, using conditional statements (IF, CASE), and checking employee statuses based on salary and experience. Each task is presented with input and expected output, attributed to different students.

Uploaded by

Dipak Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

SEM-2 ASSIGNMENT-3 FY BSC.

IT

1.Write a PL/SQL block to display “HELLO WORLD!”.


-input
SQL> begin
dbms_output.put_line('hello world!');
end;
/
-output

2.Declare and assign values to variables.


-input
SQL> declare
name varchar(40);
age number;
begin
name := 'Krina';
age := 18;

dbms_output.put_line('name:'||name||',age'||age);
end;
/
-output

RDBMS SANGANI KRINA


SEM-2 ASSIGNMENT-3 FY BSC.IT

3.Create and use a user-defined record.


-input
SQL> declare
type emp_record is RECORD(
emp_id number,
emp_name varchar2(40),
emp_salary number);
emp.emp_record;
begin
emp.emp_id := 005;
emp.emp_name := 'krina';
emp.emp_salary := 63000;
dbms_output.put_line('id:'||emp.emp_id||',name:'||emp.emp_name
||',salary:'||emp.emp_salary);

end;
/
-output

RDBMS SANGANI KRINA


SEM-2 ASSIGNMENT-3 FY BSC.IT

4.use IF…THEN statement to check if an employee’s


salary is greater than 50,000.

-input

SQL> declare
salary number := 55000;
begin
if salary > 50000 then
dbms_output.put_line('salary is greater then 50,000.');
end if;
end;
/
-output

5.use IF…ELSE to check number even or odd.


-input
SQL>declare
numnumber := 5;
begin
if mod(num,2) = 0 then
dbms_output.put_line(num || 'is even');
else
dbms_output.put_line(num || 'is odd');
end if;
end;

RDBMS SANGANI KRINA


SEM-2 ASSIGNMENT-3 FY BSC.IT

/
-output

6.use multiple conditions to display employee status


based on experience.
-input

SQL> declare
experience number := 4;
begin
if experience < 2 then
dbms_output.put_line('status: junior');
elsif experience between 2 and 5 then
dbms_output.put_line('status: mid-level');
else
dbms_output.put_line('status: senior');
end if;
end;
/
-output

7.Write a nested IF statement to check mark and


display “Excellent” or “Passed”.

RDBMS SANGANI KRINA


SEM-2 ASSIGNMENT-3 FY BSC.IT

-input
SQL> declare
marks number := 65;
begin
if marks >= 90 then
dbms_output.put_line('Excellent');
elsif marks >= 50 then
dbms_output.put_line('passed');
else
dbms_output.put_line('failed');
end if;
end;
/

-output

8.use a CASE statement to display department names


based on
-input

SQL> declare
dept_codenumber := 2;

RDBMS SANGANI KRINA


SEM-2 ASSIGNMENT-3 FY BSC.IT

dept_namevarchar(40);
begin
dept_name := case dept_code
when 1 then 'HR'
when 2 then 'PRINCIPAL'
when 3 then 'Finance'
when 4 then 'it'
else'unknowndept'
end;
dbms_output.put_line('Department:'|| dept_name);
end;
/
-output

9. THEN statement to check if an employee,s salary is


greater than 3000.
-input
SQL> declare
salary number := 8000;
begin
if salary > 3000 then

RDBMS SANGANI KRINA


SEM-2 ASSIGNMENT-3 FY BSC.IT

dbms_output.put_line('salary is greater than 3000.');


end if;
end;
/
-output

RDBMS SANGANI KRINA


SEM-2 ASSIGNMENT-3 FY BSC.IT

1.Write a PL/SQL block to display “HELLO WORLD!”.


-input
SQL> begin
dbms_output.put_line('hello world!');
end;
/
-output

2.Declare and assign values to variables.


-input
SQL> declare
name varchar(40);
age number;
begin
name := 'princy';
age := 18;

dbms_output.put_line('name:'||name||',age'||age);
end;
/
-output

RDBMS CHANGELA PRINCY


SEM-2 ASSIGNMENT-3 FY BSC.IT

3.Create and use a user-defined record.


-input
SQL> declare
type emp_record is RECORD(
emp_id number,
emp_name varchar2(40),
emp_salary number
);
empemp_record;
begin
emp.emp_id := 005;
emp.emp_name := 'Princy';
emp.emp_salary := 63000;
dbms_output.put_line('id:'||emp.emp_id||',name:'||emp.emp_name
||',salary:'||emp.emp_salary);

end;
/
-output

RDBMS CHANGELA PRINCY


SEM-2 ASSIGNMENT-3 FY BSC.IT

4.use IF…THEN statement to check if an employee’s


salary is greater than 50,000.

-input

SQL> declare
salary number := 55000;
begin
if salary > 50000 then
dbms_output.put_line('salary is greater then 50,000.');
end if;
end;
/
-output

5.use IF…ELSE to check number even or odd.


-input
SQL>declare
numnumber := 5;
begin
if mod(num,2) = 0 then
dbms_output.put_line(num || 'is even');
else
dbms_output.put_line(num || 'is odd');
end if;

RDBMS CHANGELA PRINCY


SEM-2 ASSIGNMENT-3 FY BSC.IT

end;
/
-output

6.use multiple conditions to display employee status


based on experience.
-input

SQL> declare
experience number := 4;
begin
if experience < 2 then
dbms_output.put_line('status: junior');
elsif experience between 2 and 5 then
dbms_output.put_line('status: mid-level');
else
dbms_output.put_line('status: senior');
end if;
end;
/
-output

RDBMS CHANGELA PRINCY


SEM-2 ASSIGNMENT-3 FY BSC.IT

7.Write a nested IF statement to check mark and


display “Excellent” or “Passed”.
-input
SQL> declare
marks number := 65;
begin
if marks >= 90 then
dbms_output.put_line('Excellent');
elsif marks >= 50 then
dbms_output.put_line('passed');
else
dbms_output.put_line('failed');
end if;
end;
/

-output

8.use a CASE statement to display department names


based on
-input

SQL> declare
dept_codenumber := 2;
dept_namevarchar(40);
begin
dept_name := case dept_code

RDBMS CHANGELA PRINCY


SEM-2 ASSIGNMENT-3 FY BSC.IT

when 1 then 'HR'


when 2 then 'PRINCIPAL'
when 3 then 'Finance'
when 4 then 'it'
else'unknowndept'
end;
dbms_output.put_line('Department:'|| dept_name);
end;
/
-output

9.THEN statement to check if an employee,s salary is


greater than 3000.
-input
SQL> declare
salary number := 8000;
begin
if salary > 3000 then
dbms_output.put_line('salary is greater than 3000.');
end if;
end;
/
-output

RDBMS CHANGELA PRINCY


SEM-2 ASSIGNMENT-3 FY BCA

1.Write a PL/SQL block to display “HELLO WORLD!”.


-input
SQL> begin
dbms_output.put_line('hello world!');
end;
/
-output

2.Declare and assign values to variables.


-input
SQL> declare
name varchar(40);
age number;
begin
name := 'Diya';
age := 18;

dbms_output.put_line('name:'||name||',age'||age);
end;
/
-output

RDBMS Diya Patel


SEM-2 ASSIGNMENT-3 FY BCA

3.Create and use a user-defined record.


-input
SQL> declare
type emp_record is RECORD(
emp_id number,
emp_name varchar2(40),
emp_salary number
);
empemp_record;
begin
emp.emp_id := 005;
emp.emp_name := 'Diya';
emp.emp_salary := 63000;
dbms_output.put_line('id:'||emp.emp_id||',name:'||emp.emp_name
||',salary:'||emp.emp_salary);

end;
/
-output

RDBMS Diya Patel


SEM-2 ASSIGNMENT-3 FY BCA

4.use IF…THEN statement to check if an employee’s


salary is greater than 50,000.

-input

SQL> declare
salary number := 55000;
begin
if salary > 50000 then
dbms_output.put_line('salary is greater then 50,000.');
end if;
end;
/
-output

5.use IF…ELSE to check number even or odd.


-input
SQL>declare
numnumber := 5;
begin
if mod(num,2) = 0 then

RDBMS Diya Patel


SEM-2 ASSIGNMENT-3 FY BCA

dbms_output.put_line(num || 'is even');


else
dbms_output.put_line(num || 'is odd');
end if;
end;
/
-output

6.use multiple conditions to display employee status


based on experience.
-input

SQL> declare
experience number := 4;
begin
if experience < 2 then
dbms_output.put_line('status: junior');
elsif experience between 2 and 5 then
dbms_output.put_line('status: mid-level');
else
dbms_output.put_line('status: senior');
end if;
end;
/
-output

RDBMS Diya Patel


SEM-2 ASSIGNMENT-3 FY BCA

7.Write a nested IF statement to check mark and


display “Excellent” or “Passed”.
-input
SQL> declare
marks number := 65;
begin
if marks >= 90 then
dbms_output.put_line('Excellent');
elsif marks >= 50 then
dbms_output.put_line('passed');
else
dbms_output.put_line('failed');
end if;
end;
/

-output

8.use a CASE statement to display department names


based on
-input

SQL> declare
dept_codenumber := 2;

RDBMS Diya Patel


SEM-2 ASSIGNMENT-3 FY BCA

dept_namevarchar(40);
begin
dept_name := case dept_code
when 1 then 'HR'
when 2 then 'PRINCIPAL'
when 3 then 'Finance'
when 4 then 'it'
else'unknowndept'
end;
dbms_output.put_line('Department:'|| dept_name);
end;
/
-output

9.THEN statement to check if an employee,s salary is


greater than 3000.
-input
SQL> declare
salary number := 8000;
begin
if salary > 3000 then
dbms_output.put_line('salary is greater than 3000.');
end if;
end;
/
-output

RDBMS Diya Patel


SEM-2 ASSIGNMENT-3 FY BCA

RDBMS Diya Patel

You might also like