Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

A

Micro Project
Report on

“Describe View, Sequence,


Function And Procedure”

In the fulfillment of the requirement


for Diploma in Computer Engineering

Submitted by
MR. Abak Sahil Sunil
(2111710069)

Guided By
Prof. Bhad S.A

DEPARTMENT OF COMPUTER ENGINEERING


M.I.T POLYTECHNIC DHANORE, YEOLA.
M.S.B.T.E MUMBAI.
2022-23

1
MAHARASHTRA STATE BOARD OF TECHNICAL

EDUCATION,MUMBAI.

CERTIFICATE

This is to certify that Mr.Abak Sahil Sunil satisfactorily carried out the
investigation/experimentation and micro project work entitled “Describe View,
Sequence, Function And Procedure”.
This work is being submitted for the award of diploma in Computer
Engineering. It is submitted in the partial fulfillment of the prescribed
Syllabus M.S.B.T.E Mumbai. For the academic year 2022-2023.

PROF. Bhad S.A PROF. Ghorpade M.S) Principal


(Guided By) (H.O.D

2
Evalution Sheet For Micro Project: -
Academic Year:-2022-2023 Sub & Sub Code:-DMS(22316)

Course & Course Code:-CO3I Name of Guide:-Bhad S.A

Semester: - 3rd

Title Of Project:-Describe View,Sequence, Function And Procedure

Pos:-

1. Classes are easy to implement

2. Classes gives provision for hide data from end users

Cos:-

1. Classes are difficult to understand


2. Gets complicated when function names are similar

Roll no Name Of Student Marks Out of ( Marks Out of #( Total Marks out
)For performance )For of( )
in group activity performance in
oral
presentation

19 Abak Sahil Sunil

Student signature Project Guide Signature

3
Weekly Progress Report

Sr Week Activity Performed Date signature


.no

1 1st Week Topic Discussion

2 2nd Week Topic Selection

3 3rd Week Collection of Data

4 4th Week Collection of Data

5 5th Week Analysis of Collected Data

6 6th Week Creating Report

7 7th Week Creating Report

8 8th Week Creating Report

9 9th Week Creating Report

10 10th Week Creating Report

11 11th Week Creating Report

12 12th Week Creating Report

13 13th Week Compilation of Report

14 14th Week Compilation of presentation

15 15th Week Presentation of seminar

16 16th Week Final Submission

4
Group Details:-

Sr Name of student Seat no Enrollment no


No

19 Abak Sahil Sunil 376697 2111710069

Guide Name: Bhad S.A

5
Index

Sr.No Title Page No

1. Introduction

2. What Is View,View Syntax & 7


Example

3. What Is Sequence,Sequence 8
Syntax & Example

4. What Is Function,Function 9
Syntax & Example

5. What Is Procedure 11

6. Conclusion 14

6
Views In DBMS

 A view is a virtual table that consists of columns from one or more tables.
 A virtual table is like a table containing fields but it does not contain any data.
 In run time it contains the data and after that it gets free. But table stores the
data in database occupy some space.
 Just like table, view contains Rows and Columns which is fully virtual based
table.
 Views are usually virtual and do not occupy space in systems.
 Views can be used as security mechanism
 There is no record in the view it only holds the definition of table and fetches
data from the table and shows it.
 We can create a view by selecting fields from one or more tables present in the
database.
 A View can either have all the rows of a table or specific rows based on certain
condition.

Syntax And Example:-

 CREATE VIEW view_name AS SELECT column_name(s) FROM table_name


WHERE condition

 Example

 CREATE VIEW Brazil Customers AS


SELECT CustomerName, ContactNumber
FROM Customers
WHERE Country = 'Brazil';

 SELECT * FROM Brazil Customers;

 DROP VIEW Syntax

 DROP VIEW view_nam

7
Sequence:-

Sequence is a set of integers 1, 2, 3, … that are generated and supported by some


database systems to produce unique values on demand.

 A sequence is a user defined schema bound object that generates a sequence of


numeric values.
 Sequences are frequently used in many databases because many applications
require each row in a table to contain a unique value and sequences provides an
easy way to generate them.
 The sequence of numeric values is generated in an ascending or descending
order at defined intervals and can be configured to restart when exceeds
max_value.

Syntax:

CREATE SEQUENCE sequence_name


START WITH initial_value
INCREMENT BY increment_value
MINVALUE minimum value
MAXVALUE maximum value
CYCLE|NOCYCLE ;

Sequence_name: Name of the sequence.

Initial_value: starting value from where the sequence starts.


Initial_value should be greater than or equal
to minimum value and less than equal to maximum value.

increment_value: Value by which sequence will increment itself.


Increment_value can be positive or negative.

minimum_value: Minimum value of the sequence.


maximum_value: Maximum value of the sequence.

cycle: When sequence reaches its set_limit


it starts from beginning.

nocycle: An exception will be thrown


if sequence exceeds its max_value.

8
Example:-
Following is the sequence query creating sequence in ascending order.

 CREATE SEQUENCE sequence_1


 start with 1
 increment by 1
 minvalue 0
 maxvalue 100
 cycle;
Above query will create a sequence named sequence_1.Sequence will start from 1
and will be incremented by 1 having maximum value 100. Sequence will repeat
itself from start value after exceeding 100.

Function:-

• PL/SQL functions block create using CREATE FUNCTION statement.


• A function is a relation between a set of inputs and a set of permissible
outputs with the property that each input is related to exactly one output.
Let A & B be any two non-empty sets; mapping from A to B will be a function
only when every element in set A has one end, only one image in set B.

• Syntax to create Function:-


CREATE [OR REPLACE] FUNCTION function_name [parameters]
[(parameter_name [IN | OUT | IN OUT] type [, ...])]
RETURN return_datatype
{IS | AS}

9
BEGIN
< function_body >
END [function_name];


• PL/SQL Drop Function
Functions Drop Syntax
DROP FUNCTION function_name;
DROP FUNCTION adder;

PL/SQL Function Example


Let's see a simple example to create a function.
create or replace function adder(n1 in number, n2 in nuber)

return number
is
n3 number(8);
begin
n3 :=n1+n2;
return n3;
end;
/

10
Now write another program to call the function
DECLARE
n3 number(2);
• BEGIN
n3 := adder(11,22);
dbms_output.put_line('Addition is: ' || n3);
END;
/

Output:-
Addition is: 33
Statement processed

11
Procedures:-

• The PL/SQL stored procedure or simply a procedure is a PL/SQL block which


performs one or more specific tasks.

• The procedure contains a header and a body.

• Header:- The header contains the name of the procedure and the parameters
or variables passed to the procedure.

• Body:- The body contains a declaration section, execution section and


exception section similar to a general PL/SQL block.

• PL/SQL procedures create using CREATE PROCEDURE statement. The major


difference between PL/SQL function or procedure, function return always value
where as procedure may or may not return value.

• CREATE [OR REPLACE] PROCEDURE procedure_name [(parameter_name [IN | OUT


| IN OUT]
• type [, ...])] {IS | AS} BEGIN < procedure_body > END procedure_name;

Procedure Example:-
• In this example, we are going to insert record in user table. So you need to
create user table first.
• create table user(id number(10) primary key,name varchar2(100));
• Now write the procedure code to insert record in user table.
Procedure Code:
create or replace procedure "INSERTUSER"
(id IN NUMBER,name IN VARCHAR2)
is
begin
insert into user values(id,name);

12
end; /

• Output:-
Procedure created.

• Syntax for drop procedure


DROP PROCEDURE procedure_name;
Example of drop procedure
DROP PROCEDURE pro1;

13
Conclusion

It was a great experience to design and implement the Describe View, Sequence,
Function, Procedure. System by using Database Mangement System and to work on its
documentation.While working on this project,we have learned many things especially
how to apply the concepts of Database Mangement System paradigm in modelling of
real world systems.

This assignment helped me to get the better understanding to develop and


implement It also helped me in getting in the better understanding of basic Concepts
of Database Mangement System. In this project,we have used concepts of, Database
Mangement System we have learned .We have also provided validations throughout
the system for avoiding logical errors,used excellent logic related comments with
proper indentation and the Database Mangement System concept in an excellent
manner.
After doing this project,We are in position to explain Database Mangement
System concepts and apply them to the modelling of real world systems by utilizing
its offered facilities. We have also learned how Stored functions can be used in SQL
statements or within other stored programs wherever an expression that returns a
corresponding data type can be used.

14

You might also like