0% found this document useful (0 votes)
15 views30 pages

Moi CT2 RDBMS MSC2

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

Moi CT2 RDBMS MSC2

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

1. Explain the concept of keys giving suitable example.

Keys are one of the basic requirements of a relational database model. It is


widely used to identify the tuples(rows) uniquely in the table. We also use
keys to set up relations amongst various columns and tables of a relational
database.
Different Types of Database Keys
 Candidate Key
 Primary Key
 Super Key
 Alternate Key
 Foreign Key
 Composite Key
Candidate Key
The minimal set of attributes that can uniquely identify a tuple is known as a
candidate key. For Example, STUD_NO in STUDENT relation.
 It is a minimal super key.
 It is a super key with no repeated data is called a candidate key.
 The minimal set of attributes that can uniquely identify a record.
 It must contain unique values.
 It can contain NULL values.
 Every table must have at least a single candidate key.
 A table can have multiple candidate keys but only one primary key.
 The value of the Candidate Key is unique and may be null for a
tuple.
 There can be more than one candidate key in a relationship.
Example:
STUD_NO is the candidate key for relation STUDENT.
Table STUDENT
STUD_NO SNAME ADDRESS PHONE

1 Shyam Delhi 123456789

2 Rakesh Kolkata 223365796

3 Suraj Delhi 175468965


 The candidate key can be simple (having only one attribute) or
composite as well.
Example:
{STUD_NO, COURSE_NO} is a composite
candidate key for relation STUDENT_COURSE.
Table STUDENT_COURSE
STUD_NO TEACHER_NO COURSE_NO

1 001 C001

2 056 C005
Note: In SQL Server a unique constraint that has a nullable
column, allows the value ‘null‘ in that column only once. That’s why the
STUD_PHONE attribute is a candidate here, but can not be a ‘null’ value in the
primary key attribute.
Primary Key
There can be more than one candidate key in relation out of which one can
be chosen as the primary key. For Example, STUD_NO, as well as
STUD_PHONE, are candidate keys for relation STUDENT but STUD_NO can be
chosen as the primary key (only one out of many candidate keys).
 It is a unique key.
 It can identify only one tuple (a record) at a time.
 It has no duplicate values, it has unique values.
 It cannot be NULL.
 Primary keys are not necessarily to be a single column; more than
one column can also be a primary key for a table.
Example:
STUDENT table -> Student(STUD_NO, SNAME,
ADDRESS, PHONE) , STUD_NO is a primary key
Table STUDENT
STUD_NO SNAME ADDRESS PHONE

1 Shyam Delhi 123456789

2 Rakesh Kolkata 223365796

3 Suraj Delhi 175468965


Super Key
The set of attributes that can uniquely identify a tuple is known as Super Key.
For Example, STUD_NO, (STUD_NO, STUD_NAME), etc. A super key is a group
of single or multiple keys that identifies rows in a table. It supports NULL
values.
 Adding zero or more attributes to the candidate key generates the
super key.
 A candidate key is a super key but vice versa is not true.
 Super Key values may also be NULL.
Example:
Consider the table shown above.
STUD_NO+PHONE is a super key.

Relation between Primary Key, Candidate Key, and Super Key

Alternate Key
The candidate key other than the primary key is called an alternate key.
 All the keys which are not primary keys are called alternate keys.
 It is a secondary key.
 It contains two or more fields to identify two or more records.
 These values are repeated.
 Eg:- SNAME, and ADDRESS is Alternate keys
Example:
Consider the table shown above.
STUD_NO, as well as PHONE both,
are candidate keys for relation STUDENT but
PHONE will be an alternate key
(only one out of many candidate keys).
Primary Key, Candidate Key, and Alternate Key

Foreign Key
If an attribute can only take the values which are present as values of some
other attribute, it will be a foreign key to the attribute to which it refers. The
relation which is being referenced is called referenced relation and the
corresponding attribute is called referenced attribute the relation which
refers to the referenced relation is called referencing relation and the
corresponding attribute is called referencing attribute. The referenced
attribute of the referenced relation should be the primary key to it.
 It is a key it acts as a primary key in one table and it acts as
secondary key in another table.
 It combines two or more relations (tables) at a time.
 They act as a cross-reference between the tables.
 For example, DNO is a primary key in the DEPT table and a non-key
in EMP
Example:
Refer Table STUDENT shown above.
STUD_NO in STUDENT_COURSE is a
foreign key to STUD_NO in STUDENT relation.
Table STUDENT_COURSE
STUD_NO TEACHER_NO COURSE_NO

1 005 C001

2 056 C005
It may be worth noting that, unlike the Primary Key of any given relation,
Foreign Key can be NULL as well as may contain duplicate tuples i.e. it need
not follow uniqueness constraint. For Example, STUD_NO in the
STUDENT_COURSE relation is not unique. It has been repeated for the first
and third tuples. However, the STUD_NO in STUDENT relation is a primary key
and it needs to be always unique, and it cannot be null.

Relation between Primary Key and Foreign Key

Composite Key
Sometimes, a table might not have a single column/attribute that uniquely
identifies all the records of a table. To uniquely identify rows of a table, a
combination of two or more columns/attributes can be used. It still can give
duplicate values in rare cases. So, we need to find the optimal set of
attributes that can uniquely identify rows in a table.
 It acts as a primary key if there is no primary key in a table
 Two or more attributes are used together to make a composite key.
 Different combinations of attributes may give different accuracy in
terms of identifying the rows uniquely.
Example:
FULLNAME + DOB can be combined
together to access the details of a student.

Different Types of Keys


2. What is Relational Algebra? Explain the types of Relational
Operators

Relational algebra is a procedural query language. It gives a step by step


process to obtain the result of the query. It uses operators to perform queries.

The main purpose of using Relational Algebra is to define operators that


transform one or more input relations into an output relation. Given that
these operators accept relations as input and produce relations as output,
they can be combined and used to express potentially complex queries that
transform potentially many input relations (whose data are stored in the
database) into a single output relation (the query results). As it is pure
mathematics, there is no use of English Keywords in Relational Algebra and
operators are represented using symbols.

Types of Relational operation

1. Select Operation:

o The select operation selects tuples that satisfy a given predicate.


o It is denoted by sigma (σ).

1. Notation: σ p(r)

Where:

σ is used for selection prediction


r is used for relation
p is used as a propositional logic formula which may use connectors like: AND
OR and NOT. These relational can use as relational operators like =, ≠, ≥, <, >, ≤.

For example: LOAN Relation

BRANCH_NAME LOAN_NO AMOUNT

Downtown L-17 1000

Redwood L-23 2000

Perryride L-15 1500

Downtown L-14 1500

Mianus L-13 500

Roundhill L-11 900

Perryride L-16 1300

Input:

1. σ BRANCH_NAME="perryride" (LOAN)

Output:

BRANCH_NAME LOAN_NO AMOUNT

Perryride L-15 1500

Perryride L-16 1300


2. Project Operation:

o This operation shows the list of those attributes that we wish to appear
in the result. Rest of the attributes are eliminated from the table.
o It is denoted by ∏.

1. Notation: ∏ A1, A2, An (r)

Where

A1, A2, A3 is used as an attribute name of relation r.

Example: CUSTOMER RELATION

NAME STREET CITY

Jones Main Harrison

Smith North Rye

Hays Main Harrison

Curry North Rye

Johnson Alma Brooklyn

Brooks Senator Brooklyn

Input:

1. ∏ NAME, CITY (CUSTOMER)


Output:

NAME CITY

Jones Harrison

Smith Rye

Hays Harrison

Curry Rye

Johnson Brooklyn

Brooks Brooklyn

3. Union Operation:

o Suppose there are two tuples R and S. The union operation contains all
the tuples that are either in R or S or both in R & S.
o It eliminates the duplicate tuples. It is denoted by ∪.

1. Notation: R ∪ S

A union operation must hold the following condition:

o R and S must have the attribute of the same number.


o Duplicate tuples are eliminated automatically.

Example:

DEPOSITOR RELATION

CUSTOMER_NAME ACCOUNT_NO

Johnson A-101
Smith A-121

Mayes A-321

Turner A-176

Johnson A-273

Jones A-472

Lindsay A-284

BORROW RELATION

CUSTOMER_NAME LOAN_NO

Jones L-17

Smith L-23

Hayes L-15

Jackson L-14

Curry L-93

Smith L-11

Williams L-17

Input:

1. ∏ CUSTOMER_NAME (BORROW) ∪ ∏ CUSTOMER_NAME (DEPOSITOR)


Output:

CUSTOMER_NAME

Johnson

Smith

Hayes

Turner

Jones

Lindsay

Jackson

Curry

Williams

Mayes

4. Set Intersection:

o Suppose there are two tuples R and S. The set intersection operation
contains all tuples that are in both R & S.
o It is denoted by intersection ∩.

1. Notation: R ∩ S

Example: Using the above DEPOSITOR table and BORROW table


Input:

1. ∏ CUSTOMER_NAME (BORROW) ∩ ∏ CUSTOMER_NAME (DEPOSITOR)

Output:

CUSTOMER_NAME

Smith

Jones

5. Set Difference:

o Suppose there are two tuples R and S. The set intersection operation
contains all tuples that are in R but not in S.
o It is denoted by intersection minus (-).

1. Notation: R - S

Example: Using the above DEPOSITOR table and BORROW table

Input:

1. ∏ CUSTOMER_NAME (BORROW) - ∏ CUSTOMER_NAME (DEPOSITOR)

Output:

CUSTOMER_NAME

Jackson

Hayes

Willians
Curry

6. Cartesian product

o The Cartesian product is used to combine each row in one table with
each row in the other table. It is also known as a cross product.
o It is denoted by X.

1. Notation: E X D

Example:

EMPLOYEE

EMP_ID EMP_NAME EMP_DEPT

1 Smith A

2 Harry C

3 John B

DEPARTMENT

DEPT_NO DEPT_NAME

A Marketing

B Sales

C Legal

Input:

1. EMPLOYEE X DEPARTMENT
Output:

EMP EMP_N EMP_D DEPT_ DEPT_N


_ID AME EPT NO AME

1 Smith A A Marketing

1 Smith A B Sales

1 Smith A C Legal

2 Harry C A Marketing

2 Harry C B Sales

2 Harry C C Legal

3 John B A Marketing

3 John B B Sales

3 John B C Legal

7. Rename Operation:
The rename operation is used to rename the output relation. It is denoted
by rho (ρ).

Example: We can use the rename operator to rename STUDENT relation to


STUDENT1.

1. ρ(STUDENT1, STUDENT)

3. Describe join operations in relational algebra.


Join Operations:

only if a given join condition is satisfied. It is denoted by ⋈.


A Join operation combines related tuples from different relations, if and

Example:

EMPLOYEE

EMP_CODE EMP_NAME

101 Stephan

102 Jack

103 Harry

SALARY

EMP_CODE SALARY

101 50000

102 30000

103 25000

1. Operation: (EMPLOYEE ⋈ SALARY)

Result:

EMP_CODE EMP_NAME SALARY

101 Stephan 50000


102 Jack 30000

103 Harry 25000

Types of Join operations:

1. Natural Join:

o A natural join is the set of tuples of all combinations in R and S that are
equal on their common attribute names.
o It is denoted by ⋈.

Example: Let's use the above EMPLOYEE table and SALARY table:

Input:

1. ∏EMP_NAME, SALARY (EMPLOYEE ⋈ SALARY)

Output:

EMP_NAME SALARY
Stephan 50000

Jack 30000

Harry 25000

2. Outer Join:
The outer join operation is an extension of the join operation. It is used to
deal with missing information.

Example:

EMPLOYEE

EMP_NAME STREET CITY

Ram Civil line Mumbai

Shyam Park street Kolkata

Ravi M.G. Street Delhi

Hari Nehru nagar Hyderabad

FACT_WORKERS

EMP_NAME BRANCH SALARY

Ram Infosys 10000

Shyam Wipro 20000

Kuber HCL 30000

Hari TCS 50000

Input:
1. (EMPLOYEE ⋈ FACT_WORKERS)

Output:

EMP_NAME STREET CITY BRANCH SALARY

Ram Civil line Mumbai Infosys 10000

Shyam Park street Kolkata Wipro 20000

Hari Nehru nagar Hyderabad TCS 50000

An outer join is basically of three types:

a. Left outer join


b. Right outer join
c. Full outer join

a. Left outer join:

o Left outer join contains the set of tuples of all combinations in R and S that
are equal on their common attribute names.
o In the left outer join, tuples in R have no matching tuples in S.
o It is denoted by ⟕.

Example: Using the above EMPLOYEE table and FACT_WORKERS table

Input:

1. EMPLOYEE ⟕ FACT_WORKERS

EMP_NAME STREET CITY BRANCH SALARY

Ram Civil line Mumbai Infosys 10000

Shyam Park street Kolkata Wipro 20000

Hari Nehru street Hyderabad TCS 50000


Ravi M.G. Street Delhi NULL NULL

b. Right outer join:

o Right outer join contains the set of tuples of all combinations in R and S
that are equal on their common attribute names.
o In right outer join, tuples in S have no matching tuples in R.
o It is denoted by ⟖.

Example: Using the above EMPLOYEE table and FACT_WORKERS Relation

Input:

1. EMPLOYEE ⟖ FACT_WORKERS

Output:

EMP_NAME BRANCH SALARY STREET CITY

Ram Infosys 10000 Civil line Mumbai

Shyam Wipro 20000 Park street Kolkata

Hari TCS 50000 Nehru street Hyderabad

Kuber HCL 30000 NULL NULL

c. Full outer join:

o Full outer join is like a left or right join except that it contains all rows from
both tables.
o In full outer join, tuples in R that have no matching tuples in S and tuples
in S that have no matching tuples in R in their common attribute name.
o It is denoted by ⟗.

Example: Using the above EMPLOYEE table and FACT_WORKERS table


Input:

1. EMPLOYEE ⟗ FACT_WORKERS

Output:

EMP_NAME STREET CITY BRANCH SALARY

Ram Civil line Mumbai Infosys 10000

Shyam Park street Kolkata Wipro 20000

Hari Nehru street Hyderabad TCS 50000

Ravi M.G. Street Delhi NULL NULL

Kuber NULL NULL HCL 30000

3. Equi join:
It is also known as an inner join. It is the most common join. It is based on
matched data as per the equality condition. The equi join uses the
comparison operator(=).

Example:

CUSTOMER RELATION

CLASS_ID NAME

1 John

2 Harry
3 Jackson

PRODUCT

PRODUCT_ID CITY

1 Delhi

2 Mumbai

3 Noida

Input:

1. CUSTOMER ⋈ PRODUCT

Output:

CLASS_ID NAME PRODUCT_ID CITY

1 John 1 Delhi

2 Harry 2 Mumbai

3 Harry 3 Noida

4. Differentiate between primary key and unique key along


with suitable example. What do you mean by check
constraints.
Differences between Primary Key and Unique Key
Parameters PRIMARY KEY UNIQUE KEY

Used to serve as a unique


Uniquely determines a row
Basic identifier for each row in a
that isn’t the primary key.
table.
Parameters PRIMARY KEY UNIQUE KEY

NULL value acceptance Cannot accept NULL values. Can accept NULL values.

Number of keys that


can be defined in the Only one primary key More than one unique key
table

Index Creates clustered index Creates non-clustered index

A unique key does not


A Primary key supports auto-
Auto Increment support auto-increment
increment value.
value.

We cannot change or delete We can change unique key


Modification
values stored in primary keys. values.

The primary Key is used for The Unique Key is used for
Uses
indicating the rows uniquely. preventing duplicate entries.

CREATE TABLE House


CREATE TABLE Student
(
(
House_Number INT
Student_Id INT PRIMARY
UNIQUE,
KEY,
Syntax House_Name
Student_name
VARCHAR(150),
VARCHAR(150),
House_Address
roll_number INT(10)
VARCHAR(250)
)
)

5. Consider the following table:


Table(Emp)
Columns(emp-id varchar(5), name varchar(20) not null, dept_name
varchar(20), salary numeric(8,2))
Write SQL queries for the following:
i. Create the table and insert atleast 5 values.
Create table Emp(emp-id varchar(5), name varchar(20) not null,
dept_name varchar(20), salary numeric(8,2));
Insert into Emp(emp-id , name , dept_name , salary)
values (‘1’,’Aman’,’HR’,’15000’),
(‘2’,’Ram’,’Sales’,’7000’),
(‘3’,’Mohan’,’IT’,’25000’),
(‘4’,’Ani’,’Finance’,’18000’),
(‘5’,’Nitin’,’HR’,’15000’);
ii. To display all records of the table.
Select * from Emp;
iii. To display emp-id and name of employees whose salary is
greater than 10,000.
Select emp-id,name from Emp
where salary>10000;
iv. To display the name of employee who has maximum and
minimum salary
Select max(salary), min(salary) from Emp;
v. To display emp-id and dept_name of employee whose name
starts with R and ends with n
Select emp-id, dept_name from Emp
where name like R%n;
vi. Add one column of address and insert the data
Alter table Emp add address varchar(50);
Insert into Emp (address)
values (‘Bhilai’),(‘Bhilai’),(‘Durg’),(‘Raipur’),(‘Durg’);
vii. Delete the data of employee who have less salary than 8000
Delete from Emp where salary<8000;
viii. Increase the salary of HR department by 1500
Update Emp set salary=salary+1500
Where dept_name=HR;

6. Write a PL/SQL program to calculate percentage.

Finding Percentage using Two Variables


There is no built-in operator that calculates percentages in SQL Server. You have to rely on
basic arithmetic operations i.e. (number1/number2 x 100) to find percentages in SQL Server.

Before finding the SQL percentages across rows and columns, let’s first see how you can find
percentages using two basic variables in SQL Server.

The script below defines three float variables @num1, @num2 and @perc. Next, the
@num2 variable is divided by the @num1 variable and the result is multiplied by 100 which
is stored in the @perc variable and is printed on the console.

DECLARE @num1 as FLOAT


DECLARE @num2 as FLOAT

DECLARE @perc as FLOAT


SET @num1 = 150
SET @num2 = 50

SET @perc = @num2/@num1 * 100

PRINT @perc

Output:

Finding Percentages Between Two Columns


Finding Percentages between two columns is straightforward. You can simply use the
column names and the division operator “/” to divide values in one column by another. The
result is a list of values that correspond to the result of the division of all the values in the
two columns.

Let’s see an example.

The script below, creates a table Result with two float type columns “obtained”, and “total”.
The script also inserts five dummy rows in the Result table. The SELECT query then selects all
the records in the Result table. Here is an example:

CREATE TABLE Result(obtained float, total float)


INSERT INTO Result values(15,50),(10,50),(20,50),(40,50),(25,50)

SELECT *
FROM Result

Output:

Let’s try to find percentages for each row as a result of the division between the values in
the “obtained” and “total” columns as shown below where a new column is added for
percentages.

SELECT obtained, total, obtained/total * 100 as 'percentage'


FROM Result

Finding Percentages via Subqueries


Finding SQL percentages between two columns is straightforward. However, the process is
not as straightforward for finding percentages across rows for different scenarios.
Let’s first discuss a very simple scenario where you have to find what is the percentage of a
value in a column among all the rows in the column.

The following script creates a table Scores with one column.

CREATE TABLE Scores(val float)


INSERT Scores(val) values(15),(10),(20),(40),(25);

SELECT *
FROM Scores

Output:

Now if you want to find what percent of the sum of total values in the “val” column does
each value constitutes, you can use subqueries.

In this regard, the outer query will multiply all the values in the “val” column by 100 which
will be divided by the result of the subquery which finds the sum of all the values in the
“val” column.

Let’s first see how our subquery looks that calculate the sum of the values in the “val”
column.

SELECT SUM(val) as 'Total Sum'


FROM Scores

Output:

The following script returns the percentage of the total for each value in the “val ” column.

SELECT val,
val * 100/(SELECT SUM(val) FROM Scores) as 'Percentage of Total'
From Scores
If you do not want to exclude any value while calculating the percentage of the total, you
can do so with the WHERE clause as shown in the script below where the value 40 is not
included.

SELECT val,
val * 100/(SELECT SUM(val) FROM Scores WHERE val < 40) as 'Percentage of Total' From
Scores WHERE val < 40

You can see from the above output that the values now have a larger percentage share of
total values since the value 40 is removed.

Finally, as a side note, you can round off the percentages returned using the “round”
function as shown below. The script below rounds off the percentage values to 2 decimal
places.

SELECT val,
round(val * 100/(SELECT SUM(val) FROM Scores WHERE val < 40), 2) as 'Percentage of Total'
From Scores WHERE val < 40

Output:
7. Explain packages.
PL/SQL packages are a way to organize and encapsulate
related procedures, functions, variables, triggers, and other PL/SQL items into a single
item. Packages provide a modular approach to write and maintain the code. It makes it
easy to manage large codes.
A package is compiled and then stored in the database, which then can be shared with
many applications. The package also has specifications, which declare an item to be public
or private. Public items can be referenced from outside of the package.
A PL/SQL package is a collection of related Procedures, Functions, Variables, and other
elements that are grouped for Modularity and Reusability.
The needs of the Packages are described below:
 Modularity: Packages provide a modular structure, allowing developers to
organize and manage code efficiently.
 Code Reusability: Procedures and functions within a package can be reused
across multiple programs, reducing redundancy.
 Private Elements: Packages support private procedures and functions, limiting
access to certain code components.
 Encapsulation: Packages encapsulate related logic, protecting internal details
and promoting a clear interface to other parts of the code.
PL/SQL Package
A PL/SQL package consists of two parts:
1. A package Specification.
2. A package Body.
Package Specification
The package specification declares the public interface of the package. It includes
declarations of procedures, functions, variables, cursors, and other constructs that are
meant to be accessible from outside the package. The specification is like a header file
that defines what a package can do.

Example of Package Specification


CREATE OR REPLACE PACKAGE my_package AS
PROCEDURE my_procedure(p_param1 NUMBER);
FUNCTION calculate_sum(x NUMBER, y NUMBER) RETURN NUMBER;
-- Other declarations...
END my_package;

Package Body
The package body contains the implementation of the details of the package. It includes
the coding of the procedures or functions which are decalared in the package
specification. The body can also contain private variables and procedures that are not
exposed to outside the code.
Example of Package Body
CREATE OR REPLACE PACKAGE BODY my_package AS
PROCEDURE my_procedure(p_param1 NUMBER) IS
BEGIN
-- Implementation code...
END my_procedure;

FUNCTION calculate_sum(x NUMBER, y NUMBER) RETURN NUMBER IS


BEGIN
-- Implementation code...
END calculate_sum;
-- Other implementation details...
END my_package;

Once your create your package in above two steps, you can use it in PL/SQL codes. This
allows for modular programming, code reuse, and better maintenance of the the code
base.
To Use the Package in Our Code, Follow the Below Pattern
DECLARE
result NUMBER;
BEGIN
-- Call a procedure from the package
my_package.my_procedure(42);

-- Call a function from the package


result := my_package.calculate_sum(10, 20);

-- Other code...
END;

Example 1
-- Enable the display of server output
SET SERVEROUTPUT ON;

-- Create a PL/SQL package specification


CREATE OR REPLACE PACKAGE math_operations AS
-- Procedure to add two numbers with an output parameter
PROCEDURE add_numbers(x NUMBER, y NUMBER, result OUT NUMBER);

-- Function to multiply two numbers


FUNCTION multiply_numbers(x NUMBER, y NUMBER) RETURN NUMBER;
END math_operations;
/

-- Create the body of the math_operations package


CREATE OR REPLACE PACKAGE BODY math_operations AS
-- Implementation of the add_numbers procedure
PROCEDURE add_numbers(x NUMBER, y NUMBER, result OUT NUMBER) IS
BEGIN
result := x + y;
END add_numbers;
-- Implementation of the multiply_numbers function
FUNCTION multiply_numbers(x NUMBER, y NUMBER) RETURN NUMBER IS
BEGIN
RETURN x * y;
END multiply_numbers;
END math_operations;
/

-- PL/SQL block to test the math_operations package


DECLARE
-- Declare variables to store results
sum_result NUMBER;
product_result NUMBER;
BEGIN
-- Call the procedure and pass output parameter
math_operations.add_numbers(5, 7, sum_result);
-- Display the result of the add_numbers procedure
DBMS_OUTPUT.PUT_LINE('Sum Result: ' || sum_result);

-- Call the function and retrieve the result


product_result := math_operations.multiply_numbers(3, 4);
-- Display the result of the multiply_numbers function
DBMS_OUTPUT.PUT_LINE('Product Result: ' || product_result);
END;
/

Output:

Explanation
The PL/SQL code defines a package named math_operations with a procedure
(add_numbers) and a function (multiply_numbers). The package is then implemented in a
package body, with the procedure adding two numbers and the function multiplying them.

You might also like