Professional Documents
Culture Documents
Database Management Systems Lab
Database Management Systems Lab
in
1
AIM:
To execute the DATA DEFINITION LANGUAGE (DDL) commands.
CREATING A TABLE
SYNTAX:
create table <table name> (column 1 datatype 1,
……., column n datatype n);
EXPLANATION:
EXAMPLE:
OUTPUT:
Table created.
DESC COMMAND
SYNTAX:
desc <table name>;
EXPLANATION:
EXAMPLE:
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
2
OUTPUT:
NAME NULL? TYPE
VT NUMBER
NAME VARCHAR (10)
ALTERING A TABLE
EXPLANATION:
The structure of the table can be changed using this command like add
new column, change the width of a datatype, change the datatype of a
column.
1. MODIFY
SYNTAX:
alter table <table name> modify (column datatype, …);
EXAMPLE:
OUTPUT:
Table altered.
2. ADD / DROP
SYNTAX:
alter table <table name> add/drop (column datatype, …);
EXAMPLE:
OUTPUT:
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
3
Table altered.
TRUNCATING A TABLE
SYNTAX:
truncate table <table name>;
EXPLANATION:
This command is used to delete all records stored in a table, but the
structure of the table is retained.
EXAMPLE:
OUTPUT:
Table truncated.
DROPPING A TABLE
SYNTAX:
drop table <table name>;
EXPLANATION:
EXAMPLE:
OUTPUT:
Table dropped.
RESULT:
Thus, the data definition language commands were executed and their outputs
were verified.
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
4
AIM:
To execute the DATA MANIPULATION LANGUAGE (DML) commands.
INSERT COMMANDS
SYNTAX:
insert into <table name> values (value1, value2,……, value n);
EXPLANATION:
EXAMPLE:
SQL> insert into student values (4169, ‘rameeze’);
OUTPUT:
1 row created.
SYNTAX:
insert into <table name> values (&value1, &value2,……, &value n);
EXPLANATION:
EXAMPLE:
SQL> insert into student values (&vt, ‘&name’);
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
5
OUTPUT:
Enter value for vt: 4169
Enter value for name: rameeze
Old 1: insert into student values (&vt, ‘&name’)
New 1: insert into student values (4169, ‘rameeze’)
1 row created.
SELECT COMMANDS
SYNTAX:
select * from <table name>;
EXPLANATION:
This select command is used to retrieve all the values stored in the table.
EXAMPLE:
SQL> select * from student;
OUTPUT:
VT NAME
4169 RAMEEZE
SYNTAX:
select <field name> from <table name>;
EXPLANATION:
This select command is used to retrieve the particular field values stored in
the table.
EXAMPLE:
SQL> select name from student;
OUTPUT:
NAME
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
6
RAMEEZE
SYNTAX:
select <field name> from <table name> where <search condition>;
EXPLANATION:
This select command is used to retrieve the particular field values, stored
in the table, which satisfy a required condition.
EXAMPLE:
SQL> select name from student where vt=4169;
OUTPUT:
NAME
RAMEEZE
UPDATE COMMAND
SYNTAX:
update <table name> set column1=expression, column 2=expression, ……,
column n=expression where <search condition>;
EXPLANATION:
This command is used to update (changing values in) one or two columns
of a row in a table. Specific rows can be updated based on some condition.
EXAMPLE:
SQL> update student set name=’md rameeze’ where vt =4169;
OUTPUT:
1 row updated.
SQL> select * from student;
VT NAME
4169 MD RAMEEZE
DELETE COMMAND
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
7
SYNTAX:
delete from <table name> where <search condition>;
EXPLANATION:
EXAMPLE:
SQL> delete from student where vt =4169;
OUTPUT:
1 row deleted.
no rows selected.
All changes made to the database is defined as a transaction. It is logical unit of work.
The transaction can made permanent to a database only they are committed. A transaction begins
with an executable SQL statement. The two transaction control commands are:
1. COMMIT
2. ROLLBACK
1. COMMIT:
This command is used to make all transaction changes permanent to the database.
This command erases all save point and release the transaction lock.
Syntax:
COMMIT
SAVEPOINT:
It is not a command. It is only a marker. Save point are used to divide as lengthy
transaction into smaller ones.
Syntax:
Savepoint id;
2. ROLLBACK:
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
8
Rollback commands undo all the changes made in the current transaction.
Syntax:
a. Rollback
b. Rollback to Save point id1;
The first one will rollback (undo) the entire transaction and the last one will undo all changes
made after the creation of the save point id1.
Data control language, the previous user with privileges commands the database object
(table, view, etc) of a user cant be accessed by another user without the permission of a user. The
owner can allow other user to access his object as per his diversion the permission given by a
user to another is called privilege.
i. GRANT Privilege
ii. REVOKE Privilege
Types of Privilege:
A permission granted to execute the various data definition command like Create Table,
Create Sequence, create session are called System Privilege.
Syntax:
Example:
Object Privilege:
An Object Privilege enables a user to execute some commands on the database object like
table view sequence etc. Some of the object privileges are
i. Alter
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
9
ii. Index
iii. Insert
iv. Update
v. Delete
vi. Select
vii. References
Syntax:
Grant object privilege [Object privilege] ON object to user [with grant option]
Example:
Permission granted to a user can also be taken back by the granter. This can be done by
the REVOKE command.
Syntax:
Revoke object privilege [object privilege] ON object name from user name;
Example:
RESULT:
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
10
Thus the given DML, DCL and TCL commands are successfully executed and the output
is verified.
AIM:
To write and execute queries in SQL.
1. SELECT
Output: NAME
hayes
jones
blake
2. WHERE
Output: CITY
harrison
3. FROM
Output: LOAN_ID
16
93
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
11
15
14
17
5. STRING OPERATIONS
(a) “%”.
Output: NAME
hayes
smith
(b) “_”.
Output: CITY
harrison
redwood
downtown
harrison
6. ORDERING OF TUPLES
11 roundhill 900
16 perryridge 1100
14 downtown 1500
15 perryridge 1500
17 redwood 2000
7. UNION
Example: (select name from depositor) union (select name from borrower);
Output: NAME
adams
britto
hayes
jones
smith
8. INTERSECTION
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
12
Example: (select name from depositor) intersect (select name from borrower);
Output: NAME
hayes
jones
9. AGGREGATE FUNCTIONS
(a) AVERAGE.
(b) MINIMUM.
(c) MAXIMUM.
(d) TOTAL.
Example: select name from depositor where depositor.name in (select name from
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
13
cust);
Output: NAME
hayes
jones
RESULT:
Thus, the queries in SQL were executed and the outputs were verified.
Ex.No:4 VIEWS
AIM:
To study the Simple View and Complex View and to execute them.
Views
Advantages of Views
• Views restrict access to the data because the view can display selective columns from the table.
• Views can be used to make simple queries to retrieve the results of complicated queries. For
example, views can be used to query information from multiple tables without the user knowing
how to write a join statement.
• Views provide data independence for ad hoc users and application programs. One view can be
used to retrieve data from several tables.
• Views provide groups of users access to data according to their particular criteria.
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
14
Creating a View
• You embed a subquery within the CREATE VIEW
statement.
Syntax:
CREATE [OR REPLACE] [FORCE|NOFORCE] VIEW view
[(alias[, alias]...)] AS subquery
[WITH CHECK OPTION [CONSTRAINT constraint]]
[WITH READ ONLY [CONSTRAINT constraint]];
Example:
• Create a view, EMPVU80, that contains details of
employees in department 80.
• Describe the structure of the view by using the iSQL*Plus DESCRIBE command.
Example:
DESCRIBE empvu80
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
15
salary*12
FROM employees
WHERE department_id = 50;
View created.
• Select the columns from this view by the given alias names.
Modifying a View
• Modify the EMPVU80 view by using CREATE OR REPLACE VIEW clause. Add an alias for
each column name.
• Column aliases in the CREATE VIEW clause are listed in the same order as the columns in the
subquery.
Create a complex view that contains group functions to display values from two tables.
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
16
The example on the slide creates a complex view of department names, minimum salaries,
maximum salaries, and average salaries by department. Note that alternative names have been
specified for the view. This is a requirement if any column of the view is derived from a function
or an expression. You can view the structure of the view by using the iSQL*Plus DESCRIBE
command. Display the contents of the view by issuing a SELECT statement.
SELECT *
FROM dept_sum_vu;
Removing a View
You can remove a view without losing data because a view is based on underlying tables in the
database.
Syntax:
DROP VIEW view;
Example:
DROP VIEW empvu80;
View dropped.
RESULT:
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
17
Thus, the Simple view and Complex view were executed and the outputs were verified.
AIM:
To implement FUNCTIONS AND PROCEDURES using STRUCTURED
QUERY LANGUAGE.
ALGORITHM:
PROGRAM (a):
OUTPUT:
function created.
F1 (3)
300
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
18
PROGRAM (b):
OUTPUT:
function created.
F2 (9)
The number is odd.
PROGRAM (c):
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
19
OUTPUT:
function created.
SQL> declare
a number;
begin
a: = F3 (&sal, &dept);
if a=0 then
dbms_output.put_line (‘Salary out of range.’);
else
dbms_output.put_line (‘Salary is in range and is’||a);
endif;
end;
/
OUTPUT:
Enter the value for sal: 9000
Enter the value for dept.: 01
old 4 : a: = f3(&sal, &dept);
new 4: a:= f3 (9000, 01);
RESULT:
Thus, the FUNCTIONS AND PROCEDURES were executed using SQL
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
20
Aim:
To study about the various front end tools to design forms and reports.
• Visual Basic
• Visual C++
• Java
• PHP
• HTML
Visual Basic was derived from BASIC and enables the rapid application development (RAD) of
graphical user interface (GUI) applications, access to databases using Data Access Objects,
Remote Data Objects, or ActiveX Data Objects, and creation of ActiveX controls and objects.
Scripting languages such as VBA and VBScript are syntactically similar to Visual Basic, but
perform differently.
A programmer can put together an application using the components provided with Visual Basic
itself. Programs written in Visual Basic can also use the Windows API, but doing so requires
external function declarations.
The final release was version 6 in 1998. Microsoft's extended support ended in March 2008 and
the designated successor was Visual Basic .NET (now known simply as Visual Basic).
Language features
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
21
Like the BASIC programming language, Visual Basic was designed to be easily learned and
used by beginner programmers. The language not only allows programmers to create simple GUI
applications, but can also develop complex applications. Programming in VB is a combination of
visually arranging components or controls on a form, specifying attributes and actions of those
components, and writing additional lines of code for more functionality. Since default attributes
and actions are defined for the components, a simple program can be created without the
programmer having to write many lines of code. Performance problems were experienced by
earlier versions, but with faster computers and native code compilation this has become less of
an issue.
Although programs can be compiled into native code executables from version 5 onwards, they
still require the presence of runtime libraries of approximately 1 MB in size. This runtime is
included by default in Windows 2000 and later, but for earlier versions of Windows like
95/98/NT it must be distributed together with the executable.
Forms are created using drag-and-drop techniques. A tool is used to place controls (e.g., text
boxes, buttons, etc.) on the form (window). Controls have attributes and event handlers
associated with them. Default values are provided when the control is created, but may be
changed by the programmer. Many attribute values can be modified during run time based on
user actions or changes in the environment, providing a dynamic application. For example, code
can be inserted into the form resize event handler to reposition a control so that it remains
centered on the form, expands to fill up the form, etc. By inserting code into the event handler
for a key press in a text box, the program can automatically translate the case of the text being
entered, or even prevent certain characters from being inserted.
Visual Basic can create executables (EXE files), ActiveX controls, or DLL files, but is primarily
used to develop Windows applications and to interface database systems. Dialog boxes with less
functionality can be used to provide pop-up capabilities. Controls provide the basic functionality
of the application, while programmers can insert additional logic within the appropriate event
handlers. For example, a drop-down combination box will automatically display its list and allow
the user to select any element. An event handler is called when an item is selected, which can
then execute additional code created by the programmer to perform some action based on which
element was selected, such as populating a related list.
Alternatively, a Visual Basic component can have no user interface, and instead provide ActiveX
objects to other programs via Component Object Model (COM). This allows for server-side
processing or an add-in module.
The language is garbage collected using reference counting, has a large library of utility objects,
and has basic object oriented support. Since the more common components are included in the
default project template, the programmer seldom needs to specify additional libraries. Unlike
many other programming languages, Visual Basic is generally not case sensitive, although it will
transform keywords into a standard case configuration and force the case of variable names to
conform to the case of the entry within the symbol table. String comparisons are case sensitive
by default, but can be made case insensitive if so desired.
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
22
The Visual Basic compiler is shared with other Visual Studio languages (C, C++), but
restrictions in the IDE do not allow the creation of some targets (Windows model DLLs) and
threading models.
Characteristics
Visual Basic has the following traits which differ from C-derived languages:
History
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
23
The predecessor to Visual C++ was called Microsoft C/C++. There was also a Microsoft QuickC
2.5 and a Microsoft QuickC for Windows 1.0.
16-bit versions
• Microsoft C 1.0, based on Lattice C, was Microsoft's first C product in 1983. It was not
K&R C.
• C 2.0 added large model support.
• C 3.0 was the first version developed inside Microsoft. It was extremely compatible with
K&R and the later ANSI standard. It was being used inside Microsoft (for Windows and
Xenix development) in early 1984. It shipped as a product in 1985.
• C 4.0 added optimizations and CodeView, a source level debugger.
• C 5.0 added loop optimizations and Huge Model (arrays bigger than 64k) support.
Microsoft FORTRAN and the first 32 bit compiler for 80386 were also part of this project.
• C 6.0 released in 1989. It added global flow analysis, a source browser, and a new
debugger, and included an optional C++ front end.
• C/C++ 7.0 was released in 1992. It added built-in support for C++ and MFC 1.0.[2]
• Visual C++ 1.0, which included MFC 2.0, was the first version of Visual C++, released
in February 1993. It was Cfront 2.1 compliant[3] and available in two editions:[4]
o Standard – replaced QuickC for Windows.
o Professional – replaced C/C++ 7.0. Included the ability to build both DOS and
Windows applications, an optimizing compiler, a source profiler, and the Windows 3.1
SDK.[3] The Phar Lap 286 DOS Extender Lite was also included.[5]
• Visual C++ 1.5 was released in December 1993, included MFC 2.5, and added OLE 2.0
and ODBC support to MFC.[6] It was the first version of Visual C++ that came only on CD-
ROM.
o Visual C++ 1.51 and 1.52 were available as part of a subscription service.
o Visual C++ 1.52b is similar to 1.52, but does not include the Control
Development Kit.
o Visual C++ 1.52c was a patched version of 1.5. It is the last, and arguably most
popular, development platform for Microsoft Windows 3.x. It is available through
Microsoft Developer Network.
32-bit versions
• Visual C++ 1.0 (original name: Visual C++ 32-bit Edition) was the first version for 32-
bit development. Although released when 16-bit 1.5 was available, it did not include
support for OLE2 and ODBC. It was also available in a bundle called Visual C++ 16/32-
bit Suite, which included Visual C++ 1.5.
• Visual C++ 2.0, which included MFC 3.0, was the first version to be 32-bit only. In
many ways, this version was ahead of its time, since Windows 95, then codenamed
"Chicago", was not yet released, and Windows NT had only a small market share. As a
result, this release was almost a "lost generation". Microsoft included and updated Visual
C++ 1.5 as part of the 2.x releases up to 2.1, which included Visual C++ 1.52, and both
16-bit and 32-bit version of the Control Development Kit (CDK) were included. Visual
C++ 2.x also supported Win32s development. It is available through Microsoft Developer
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
24
Network. There was a Visual C++ 2.0 RISC Edition for MIPS and Alpha processors, as
well as a cross-platform edition for the Macintosh (68000 instruction set).
o Visual C++ 2.1 and 2.2 were updates for 2.0 available through subscription.
• Visual C++ 4.0, which included MFC 4.0, was designed for Windows 95 and Windows
NT. To allow support of legacy (Windows 3.x/DOS) projects, 4.0 came bundled with the
Visual C++ 1.52 installation CD. Updates available through subscription included Visual
C++ 4.1, which came with the Microsoft Game SDK (later released separately as the
DirectX SDK), and Visual C++ 4.2. Version number 3.0 was skipped to achieve version
number parity between Visual C++ 4.0 and MFC 4.0.[9]
[10]
• Visual C++ 4.2 did not support Windows 3.x (Win32s) development. This was the
final version with a cross-platform edition for the Macintosh available and it differed
from the 2.x version in that it also allowed compilation for the PowerPC instruction set.
[11]
• Visual C++ 5.0, which included MFC 4.21, was a major upgrade from 4.2. Available
in four editions:
o Learning
o Professional
o Enterprise
o RISC
• Visual C++ 6.0 (commonly known as VC6), which included MFC 6.0, was released in
1998.[16] The release was somewhat controversial since it did not include an expected
update to MFC. Visual C++ 6.0 is still quite popular and often used to maintain legacy
projects. There are, however, issues with this version under Windows XP, especially
under the debugging mode (for example, the values of static variables do not display).
The debugging issues can be solved with a patch called the "Visual C++ 6.0 Processor
Pack".
• Visual C++ .NET 2002 (known also as Visual C++ 7.0), which included MFC 7.0, was
released in 2002 with support for link time code generation and debugging runtime
checks, .NET 1.0, and Visual C# and Managed C++. The new user interface used many
of the hot keys and conventions of Visual Basic, which accounted for some of its
unpopularity among C++ developers
• Visual C++ .NET 2003 (known also as Visual C++ 7.1), which included MFC 7.1, was
released in 2003 along with.NET 1.1 and was a major upgrade to Visual C++ .NET 2002.
It was considered a patch to Visual C++ .NET 2002. Accordingly, the English language
upgrade version of Visual Studio .NET 2003 shipped for minimal cost to owners of the
English language version of Visual Studio .NET 2002. This was the last version to
support Windows 95 and NT 4.0 as a target.
• eMbedded Visual C++ in various versions was used to develop for some versions of the
Windows CE operating system. Initially it replaced a development environment
consisting of tools added onto Visual C++ 6.0. eMbedded Visual C++ was replaced as a
separate development environment by Microsoft Visual Studio 2005.
• Visual C++ 2005 (known also as Visual C++ 8.0), which included MFC 8.0, was
released in November 2005. This version supports .NET 2.0 and dropped Managed C++
for C++/CLI. Managed C++ for CLI is still available via compiler options though. It also
introduced OpenMP. With Visual C++ 2005, Microsoft also introduced Team Foundation
Server. Visual C++ 8.0 has problems compiling MFC AppWizard projects that were
created using Visual Studio 6.0, so maintenance of legacy projects can be continued with
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
25
the original IDE if rewriting was not feasible. Visual C++ 2005 is the last version to be
able to target Windows 98 and Windows Me.
• SP1 version also available in Microsoft Windows SDK Update for Windows Vista.
Version number: 14.00.50727.762
• Visual C++ 2008 (known also as Visual C++ 9.0) was released in November 2007. This
version supports .NET 3.5. Managed C++ for CLI is still available via compiler options.
By default, all applications compiled against the Visual C++ 2008 Runtimes (static and
dynamic linking) will only work under Windows 2000 and later. A feature pack released
for VC9, later included into SP1, added support for C++ TR1 library extensions.
• Visual C++ 2010 (known also as Visual C++ 10.0) was released on April 12, 2010, and
it is currently the latest stable release. It uses a SQL Server Compact database to store
information about the source code, including IntelliSense information, for better
IntelliSense and code-completion support.[22] (However, Visual C++ 2010 does not
support Intellisense for C++/CLI.[23]) This version adds a modern C++ parallel computing
library called the Parallel Patterns Library, partial support for C++0x, significantly
improved IntelliSense, and performance improvements to both the compiler and
generated code.[24] This version is built around .NET 4.0, but supports compiling to
machine code. The partial C++0x support mainly consists of six compiler features[25]
(lambdas, rvalue references, auto, decltype, static_assert, nullptr), and some library
features (e.g. moving the TR1 components from std::tr1 namespace directly to std
namespace). Variadic templates were also considered, but delayed until some future
version due to lower priority which stemmed from the fact that unlike other costly-to-
implement features (lambda, rvalue references), this one would benefit only a minority of
library writers than the majority of compiler end users.[26] By default, all applications
compiled against the Visual C++ 2010 Runtimes will only work under Windows XP SP2
and later.
o Beta 2 version number: 16.00.21003.01 (this is the version of compiler; the IDE
itself has version number 16.00.21006.01)[27]
o RC version number: 16.00.30128.01
o RTM version, also available in Windows SDK for Windows 7 and .NET
Framework 4 (WinSdk v7.1).[28] Version number: 16.00.30319.01
o SP1 version, also available in KB2519277 update to Windows SDK v7.1:
16.00.40219.01
64-bit versions
Visual Studio 2005 Standard and Professional editions have x86-64 compiler support,
and Visual Studio 2008 Team Suite supports both x86-64 and IA-64. Prior to Visual C++ 2005,
the Platform SDK was the only way for programmers to develop 64-bit Windows applications.
The SDK included both a compiler and a Visual C++ 6.0 library for the IA64-target.
Programmers who wanted the 64-bit versions of the Visual C++ .NET 2003 libraries (which are
no longer available) had to contact libs7164microsoft.com.
3. JAVA
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
26
The original and reference implementation Java compilers, virtual machines, and class libraries
were developed by Sun from 1995. As of May 2007, in compliance with the specifications of the
Java Community Process, Sun relicensed most of its Java technologies under the GNU General
Public License. Others have also developed alternative implementations of these Sun
technologies, such as the GNU Compiler for Java and GNU Class path.
Principles
There were five primary goals in the creation of the Java language:
Versions
Features of Java
Java Platform
One characteristic of Java is portability, which means that computer programs written in
the Java language must run similarly on any hardware/operating-system platform. This is
achieved by compiling the Java language code to an intermediate representation called Java byte
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
27
code, instead of directly to platform-specific machine code. Java byte code instructions are
analogous to machine code, but are intended to be interpreted by a virtual machine (VM) written
specifically for the host hardware. End-users commonly use a Java Runtime Environment (JRE)
installed on their own machine for standalone Java applications, or in a Web browser for Java
applets.
Standardized libraries provide a generic way to access host-specific features such as graphics,
threading, and networking.
A major benefit of using byte code is porting. However, the overhead of interpretation means
that interpreted programs almost always run more slowly than programs compiled to native
executables would. Just-in-Time compilers were introduced from early stages that compile byte
codes to machine code during runtime.
Performance
Programs written in Java have a reputation for being slower and requiring more memory than
those written in C.[26] However, Java programs' execution speed improved significantly with the
introduction of Just-in-time compilation in 1997/1998 for Java 1.1, the addition of language
features supporting better code analysis (such as inner classes, String Buffer class, optional
assertions, etc.), and optimizations in the Java Virtual Machine itself, such as Hotspot becoming
the default for Sun's JVM in 2000. Currently, Java 2.0 code has approximately half the
performance of C code.
Java uses an automatic garbage collector to manage memory in the object lifecycle. The
programmer determines when objects are created, and the Java runtime is responsible for
recovering the memory once objects are no longer in use. Once no references to an object
remain, the unreachable memory becomes eligible to be freed automatically by the garbage
collector. Something similar to a memory leak may still occur if a programmer's code holds a
reference to an object that is no longer needed, typically when objects that are no longer needed
are stored in containers that are still in use. If methods for a nonexistent object are called, a "null
pointer exception" is thrown.
4.HTML
HTML Tags
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
28
The purpose of a web browser (like Internet Explorer or Firefox) is to read HTML documents and display them as web pages.
The browser does not display the HTML tags, but uses the tags to interpret the content of the page:
Editing HTML
HTML can be written and edited using many different editors like Dreamweaver and Visual Studio.
However, in this tutorial we use a plain text editor (like Notepad) to edit HTML. We believe using a plain text editor is the best
way to learn HTML.
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
29
Result:
Thus the front-end languages like VB, VC++, Java, and HTML are studied.
AIM:
To implement the operations of PAYROLL PROCESSING SYSTEM using the visual basic
as front end and oracle as back end to design a forms..
PROCEDURE:
1. Collect the details of how the program is expected by the user and also the atmosphere in which it is
going to work.
2. Collect the user requirement. Develop a sketch of the program about how it is going to appear
in its final design.
3. Implement the various diagram carefully, based on which the entire project design is going to
be developed.
5. In the component diagram, using the update code command we generate the code for the
required program.
SQL TABLE:
Table created.
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
30
CODING:
FORM 1:
Dim db As Database
Dim rs As Recordset
Dim PF As Integer
Dim HRA As Integer
Dim DA As Integer
Dim GROSSPAY As Integer
Dim NETPAY As Integer
Dim TOTDED As Integer
Dim TAX As Integer
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
31
txtdept.Text=””
txtbasic.Text=””
rs.AddNew
txteno.SetFocus
End sub
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
32
HRA=Val(txtbasic.Text) *0.15
DA=Val(txtbasic.Text) *0.4
MA=200
PF=700
TAX=Val(txtbasic.Text) *0.15
End If
If(Val(txtbasic.Text)>=8000) Then
HRA=Val(txtbasic.Text) *0.2
DA=Val(txtbasic.Text) *0.5
MA=300
PF=800
TAX=Val(txtbasic.Text) *0.2
End If
GROSSPAY= Val(txtbasic.Text)+HRA+DA+MA
NETPAY= GROSSPAY-(PF+TAX)
rs.AddNew
rs(0)= Val(txteno.Text)
rs(1)= Trim(txtename.Text)
rs(2)= Trim(txtdes.Text)
rs(3)= Trim(txtdept.Text)
rs(4)= Val(txtbasic.Text)
rs(5)= DA
rs(6)= HRA
rs(7)= PF
rs(8)= MA
rs(9)= GROSSPAY
rs(10)= NETPAY
rs(11)= TAX
rs.Update
MsgBox”Record updated successfully”
txteno.Text=””
txtename.Text=””
txtdes.Text=””
txtdept.Text=””
txtbasic.Text=””
End sub
FORM2:
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
33
Dim db As Database
Dim rs As Recordset
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
34
txtma.Text=rs(7)
txtpf.Text=rs(8)
txttax.Text=rs(9)
txtgross.Text=rs(10)
txtnetpay.Text=rs(11)
End sub
Form 1:
Form 2:
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
35
RESULT:
Thus, the payroll processing system using VB was implemented.
EXP.N0:8 TRIGGERS
AIM:
To create TRIGGERS on the database using SQL.
ALGORITHM:
• End.
PROGRAM (a):
INPUT:
EMPLOY
EMPNO SALARY
10 900
11 1000
12 1200
SALDET
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
36
begin
update saldet set total = total+1500 where
empno =:new.empno;
end;
/
OUTPUT:
trigger created.
EMPLOY
EMPNO SALARY
10 1000
11 1000
12 1200
SALDET
PROGRAM (b):
OUTPUT:
trigger created.
Error at line 1:
ORA -20001: You are not allowed to insert.
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
37
PROGRAM (c):
INPUT:
STUDENT
OUTPUT:
trigger created.
Error at line 1:
ORA -20001: mark1 should be less than mark2.
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
38
RESULT:
Thus, the TRIGGERS were executed using SQL and the outputs were verified.
Ex.No:9 MENU DESIGN
Aim:
To implement the operation of a menu design using the vc++ as a front end and oracle as
bank end.
ALGORITHM
Step 1: Collect the details of how the program is expected from the user and develop the
front end using Visual C++.
Step 2: Collect the user requirements. Develop the sketch on the program.
Step 3: Implement the various diagrams carefully, based on which the entire project design
is going to be developed.
Step 4: Thus the program is implemented successfully.
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
39
Program:
#include "stdafx.h"
#include "ex14a.h"
#include "ex14aDoc.h"
#include "ex14aView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = FILE ;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEx14aView
IMPLEMENT_DYNCREATE(CEx14aView, CView)
BEGIN_MESSAGE_MAP(CEx14aView, CView)
//{{AFX_MSG_MAP(CEx14aView) ON_COMMAND(ID_DRAW_CIRCLE,
OnDrawCircle) ON_UPDATE_COMMAND_UI(ID_DRAW_CIRCLE,
OnUpdateDrawCircle) ON_COMMAND(ID_DRAW_PATTERN,
OnDrawPattern) ON_UPDATE_COMMAND_UI(ID_DRAW_PATTERN,
OnUpdateDrawPattern) ON_COMMAND(ID_DRAW_SQUARE, OnDrawSquare)
ON_UPDATE_COMMAND_UI(ID_DRAW_SQUARE, OnUpdateDrawSquare)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEx14aView construction/destruction
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
40
CEx14aView::~CEx14aView()
{
}
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CEx14aView drawing
if (m_bPattern) {
pDC->SelectObject(&brush);
}
else {
pDC->SelectStockObject(WHITE_BRUSH);
}
if (m_bCircle) {
pDC->Ellipse(m_rect);
}
else {
pDC->Rectangle(m_rect);
}
pDC->SelectStockObject(WHITE_BRUSH); // Deselects brush
// if selected
}
/////////////////////////////////////////////////////////////////////////////
// CEx14aView diagnostics
#ifdef _DEBUG
void CEx14aView::AssertValid() const
{
CView::AssertValid();
}
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
41
/////////////////////////////////////////////////////////////////////////////
// CEx14aView message handlers
void CEx14aView::OnDrawCircle()
{
m_bCircle = TRUE;
m_rect += CPoint(25, 25);
InvalidateRect(m_rect);
}
void CEx14aView::OnUpdateDrawCircle(CCmdUI* pCmdUI)
{
pCmdUI->Enable(!m_bCircle);
}
void CEx14aView::OnDrawPattern()
{
m_bPattern ^= 1;
}
void CEx14aView::OnUpdateDrawPattern(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_bPattern);
}
void CEx14aView::OnDrawSquare()
{
m_bCircle = FALSE;
m_rect += CPoint(25, 25);
InvalidateRect(m_rect);
}
void CEx14aView::OnUpdateDrawSquare(CCmdUI* pCmdUI)
{
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
42
pCmdUI->Enable(m_bCircle);
}
Result:
Thus the operations of a menu design using the vc++ as a front end and oracle as bank
end as implemented and verified successfully.
Ex.No:10 REPORTS - BANKING SYSTEM
AIM
To implement the operation of a banking system using the vb on front end and oracle as
bank end.
ALGORITHM
Step 1 : Collect the details of how the program is expected by the user and also the
atmosphere in which it is going to work.
Step 2 : Collect the user requirements. Develop the sketch on the program.
Step 3 : Implement the various diagrams carefully, based on which the entire project
design is going to be developed.
Step 4 : Thus the program is implemented successfully.
SQL TABLE
PROGRAM
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
43
Else
If Combo2.Text = "transaction" Then
Form4.Show
Else
If Val(Label10.Caption) >= 501 Then
If Val(Label10.Caption) - Val(Text6.Text) >= 500 Then
Label10.Caption = Val(Label10.Caption) - Val(Text6.Text)
rec.Update
Else
MsgBox "min amt is 500", vbCritical, "below 500"
End If
Else
MsgBox "min amt is 500", vbCritical, "below 500"
End If
End If
End If
accept.Enabled = False
End Sub
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
44
Text5.Text = rec.Fields("amt")
End Sub
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
45
End If
showrec
End Sub
Private Sub clear()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub
FORM 2
Dim db As Database
Dim rec As Recordset
Dim rec1 As Recordset
Private Sub Command1_Click()
Form3.Show
End Sub
End Sub
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
46
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
End Sub
FORM 3
Dim db As Database
Dim rec As Recordset
Private Sub Add_Click()
rec.AddNew
rec(0) = Text1.Text
rec(1) = Text2.Text
rec(2) = Text3.Text
rec(3) = Text4.Text
rec(4) = Text5.Text
rec(5) = Text6.Text
rec.Update
MsgBox "record updated", vbInformation, "ok"
Unload Me
End Sub
FORM 4
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
47
Dim db As Database
Dim rec As Recordset
Dim a As Integer
Private Sub Command1_Click()
Do While Not rec.EOF
If (StrComp(rec.Fields("acno"), Val(Text1.Text)) = 0) Then
If (rec.Fields("amt") >= 501) Then
a = rec.Fields("amt") - Val(Text3.Text)
If (a >= 501) Then
rec.Fields("amt") = rec.Fields("amt") - Text3.Text
rec.Update
Do While Not rec.EOF
If (StrComp(rec.Fields("acno"), Val(Text2.Text)) = 0) Then
rec.Fields("amt") = rec.Fields("amt") + Val(Text3.Text)
rec.Update
End If
rec.MoveNext
Loop
Else
MsgBox "access denied", vbCritical, "below 500"
End If
Else
MsgBox "access denied", vbCritical, " below 500"
End If
MsgBox "transaction successfully completed"
End If
rec.MoveNext
Loop
End Sub
FORM 1:
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
48
FORM 2:
FORM 3:
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
49
FORM 4:
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
50
RESULT:
Thus, the Banking management system using VB was implemented.
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
51
EXTRA PROGRAMS
AGGREGATE FUNCTIONS
AIM:
To study the AGGREGATE FUNCTIONS and to execute them.
GROUP FUNCTIONS
Unlike single-row functions, group functions operate on sets of rows to give one result
per group. These sets may be the whole table or the table split into groups.
• AVG
• COUNT
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
52
• MAX
• MIN
• STDDEV
• SUM
• VARIANCE
Function Description
Each of the functions accepts an argument. The following table identifies the options that you
can use in the syntax:
INPUT:
EMPLOYEES
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
53
• The data types for the functions with an expr argument may be CHAR, VARCHAR2,
NUMBER, or DATE.
• All group functions ignore null values. To substitute a value for null values, use the NVL,
NVL2, or COALESCE functions.
• The Oracle server implicitly sorts the result set in ascending order when using a GROUP BY
clause. To override this default ordering, DESC can be used in an ORDER BY clause.
You can use the MAX and MIN functions for any data typ.
EXAMPLE
The following example displays the employee last name that is first and the employee last name
that is the last in an alphabetized list of all employees.
Note: AVG, SUM, VARIANCE, and STDDEV functions can be used only with numeric data
types.
1. •COUNT(*)
2. • COUNT(expr)
3. • COUNT(DISTINCT expr)
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
54
1. COUNT(*) returns the number of rows in a table that satisfy the criteria of the SELECT
statement, including duplicate rows and rows containing null values in any of the columns. If a
WHERE clause is included in the SELECT statement, COUNT(*) returns the number of rows
that satisfies the condition in the WHERE clause.
EXAMPLE
SELECT COUNT(*) FROM employees WHERE department_id = 50;
2. In contrast, COUNT(expr) returns the number of non-null values in the column identified by
expr.
EXAMPLE
Display the number of department values in the EMPLOYEES table.
3. COUNT(DISTINCT expr) returns the number of unique, non-null values in the column
identified by expr.
EXAMPLE
SELECT COUNT(DISTINCT department_id)
FROM employees;
EXAMPLE
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
55
[WHERE condition]
[GROUP BY group_by_expression]
[ORDER BY column];
EXAMPLE
When using the GROUP BY clause, make sure that all columns in the SELECT list that are not
group functions are included in the GROUP BY clause.
EXAMPLE
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
56
The WHERE clause cannot be used to restrict groups. The SELECT statement on the slide
results in an error because it uses the WHERE clause to restrict the display of average salaries of
those departments that have an average salary greater than $8,000.You can correct the slide error
by using the HAVING clause to restrict groups.
EXAMPLE
group_condition restricts the groups of rows returned to those groups for which
the specified condition is true.
The Oracle server performs the following steps when you use the HAVING clause:
1. Rows are grouped.
2. The group function is applied to the group.
3. The groups that match the criteria in the HAVING clause are displayed.
The HAVING clause can precede the GROUP BY clause, but it is recommended that you place
the GROUP BY clause first because that is more logical. Groups are formed and group functions
are calculated before the HAVING clause is applied to the groups in the SELECT list.
SELECT MAX(AVG(salary))
FROM employees
GROUP BY department_id;
Copyright : VidyarthiPlus.in
www.VidyarthiPlus.in
57
RESULT:
Thus, the AGGREGATE FUNCTIONS were executed and the outputs
were verified.
Copyright : VidyarthiPlus.in