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

princy

The document contains a series of PL/SQL programming exercises for a BSC.IT assignment. It includes examples of displaying messages, declaring variables, using records, and implementing conditional statements such as IF...THEN, IF...ELSE, and CASE. Each exercise is presented with input code and expected output.

Uploaded by

hiren.jodhani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

princy

The document contains a series of PL/SQL programming exercises for a BSC.IT assignment. It includes examples of displaying messages, declaring variables, using records, and implementing conditional statements such as IF...THEN, IF...ELSE, and CASE. Each exercise is presented with input code and expected output.

Uploaded by

hiren.jodhani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy