Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
INDEX
6 Embedded SQL
://
tp
7
Normalization
1
http://csetube.tk/
EX NO: 1 Date:
DDL commands:
Example Query:
Syntax:
ALTER TABLE[ owner_name ] table_name
://
Example Query:
Example Query:
RESULT:
Thus the DDL commands in RDBMS are implemented.
http://csetube.tk/
EX NO: 1 Date:
CREATING TABLES
STUDENT TABLE
EXAM TABLE
://
number(7,2));
ht
http://csetube.tk/
EX NO: 1 Date:
MARK TABLE
GRADE CHAR(4)
et
cs
ALTERING TABLE
://
tp
http://csetube.tk/
EX NO: 2 Date:
DATA MANIPULATION LANGUAGE (DML) and DATA
CONTROL LANGUAGE (DCL) commands in RDBMS
AIM:
To implement the DML and DCL commands in RDBMS.
DML commands:
1.Command: SELECT
Syntax:
SELECT[ALL | DISTINCT] select list
FROM table_name1[,…table_nameN]
[JOIN join_condition]
[WHERE search_condition]
Example Query:
k/
e.t
SELECT * FROM STUDENT WHERE ROLLNO=1;
ub
et
2.Command: INSERT
cs
Syntax:
://
INSERT INTO[[database_name]owner]{table_name|view_name}
tp
[(column_list)]{[DEFAULT]VALUES|VALUES(value[…])|SELECT
ht
Statement}
Example Query:
4.Command: DELETE
Syntax:
DELETE[FROM] table_name WHERE search_condition]
http://csetube.tk/
EX NO: 2 Date:
Example Query:
DCL commands
1.Command: GRANT
Syntax:
GRANT permissions ON objects TO account
2.Command: REVOKE
Syntax: k/
e.t
REVOKE permissions ON object FROM account
ub
Example Query:
et
1. 1. Create a table student with field roll no student name ,dept marks ,Average ,grade
tp
http://csetube.tk/
EX NO: 2 Date:
2. Insert the values for the tables.
26-
tp
B.tech 42
1 Sudesh 79.8 Distctn Pass DEC-
ht
IT Thinanur
87
4. Select the Student those who are not belong to Mech Dept.
ROLLNO STUDENTNAME DEPT AVERAGE GRADE STATUS DOB ADRESS
26-
B.tech 42
1 Sudesh 79.8 Distctn Pass DEC-
IT Thinanur
87
25-
3 Thomas Ece 80.8 Distctn Pass JUN- 82new
88
http://csetube.tk/
EX NO: Date:
5. Select Student detailo from obtain grade Distinc in the Examinaation.
7. Retrive the name and address of all the studens who are in IT department.
http://csetube.tk/
EX NO: Date:
8. Update the percentage of the student whose roll no is 1.
26-
ht
B.tech 42
1 Sudesh 86 Distctn Pass DEC-
IT Thinanur
87
16-
3
2 Sudharsan Mech 77.8 Distctn Pass JUN-
pattabiram
88
25-
3 Thomas Ece 80.8 Distctn Pass JUN- 82new
88
http://csetube.tk/
EX NO: Date:
11. create a table employee with empname salary
EMPNAME
Sudhir
Sudeesh
13. List the name of all the employee other than Manager.
EMPNAME
Arjit
Bai
http://csetube.tk/
EX NO: Date:
14. find the sum of the salary of all employee of Manager department as well as Max and Minimum
salary.
15. Find the sum of salary of all Employee of manager Department as well as Max salary and Minimum
salary.
DCL commands
://
1.Command: GRANT
tp
Syntax:
ht
2.Command: REVOKE
Syntax:
REVOKE permissions ON object FROM account
Example Query:
REVOKE SELECT ON student FROM username;
RESULT:
Thus the DML and DCL commands in RDBMS are implemented
http://csetube.tk/
EX NO: 3 Date:
1. PL/SQL:
PL/SQL stands for procedural structural language/SQL. PL/SQL
extends SQL by adding control structures found in other structural languages.
PL/SQL can be used in the Oracle relational database in the Oracle server and
in the client side application development tools.
SYNTAX:
APL/SQL block can divide into three parts namely,
i) Declarative part, k/
e.t
ii) Executable part, and
ub
DECLARE
tp
Declarations
ht
BEGIN
Executable statements
EXCEPTION
Handlers
END;
2. ATTRIBUTES:
Attributes allows us to refer data types and objects from database. PL/SQL
constants and variables have attributes. The following are the types of attributes supported by the
PL/SQL,
%type
%row type
http://csetube.tk/
EX NO: 3 Date:
%type:
%type is used when declaring variables that refer to database columns.
SYNTAX:
Variablename tablename.Column %type;
%rowtype:
%rowtype attributes provides a record type that rapresents a row in the tablw. The
record can store an entire row of data selected from the table or fetched by a cursor.
SYNTAX:
Variablename tablename %rowtype;
3. CURSORS:
Oracle allocates a memory known as the context area for the processing of the SQL
k/
statements. A cursor is a pointer or handle to the context area. Through the cursor, a PL/SQL
e.t
program can control the context area and what happens to it as the statement is processed.
ub
Static cursors
cs
Dynamic cursors
://
REF cursors
tp
Static cursors are the ones whose select statements are known at the compile time. These are further
ht
classified into
Explicit cursors
Implicit cursors
http://csetube.tk/
EX NO: 3 Date:
dif:=a-b;
dbms_output.put_line(‘The Difference is’||dif);
pro:=a*b;
dbms_output.put_line(‘The Product is’||pro);
div:=a/b;
dbms_output.put_line(‘The Quotent is’||div);
end;
OUTPUT:
Old 10:b:=&b;
cs
New 10:b:=4;
://
The Sum is 29
tp
The Difference is 21
ht
RESULT:
Thus the PL/SQL program using the cursors were executed successfully.
http://csetube.tk/
EX NO: 4 Date:
TRIGGER:
A database trigger is stored procedure that is fired when an insert, update or delete
statement is issued against the associated table. Database triggers can be used for the following
purposes.
To generate data automatically.
To enforce complex integrity constraints.
To customize complex security authorizations.
To maintain replicate tables.
To audit data modifications.
k/
e.t
Syntax for creating Triggers:
ub
[when <condition>]
://
tp
Types of Triggers:
ht
The triggers are classified into the following types based on when they are fired:
Before
After
For each row
For each statement (default)
INSERT:
--create or replace trigger ins1 before insert on emp
--begin
--raise_application_error(-20001.’you cannot insert a row’);
--end;
OUTPUT:
SQL>insert into emp values(&eid,’&name’,’&dob’,’&addr’,’&sex’,’&dept’,’&salary);
insert into emp
values(&eid,’&name’,’&dob’,’&addr’,’&sex’,’&dept’,’&salary);
http://csetube.tk/
EX NO: 4 Date:
ERROR at line 1:
ORA-20001: you cannot insert a row
ORA-06512: at “SCOTT.ins1”, line 2
ORA-04088: error during execution of trigger ‘SCOTT.ins1’
DELETE:
--create or replace trigger del1 before delete on emp
--begin
--raise_application_error(-20001.’you cannot delete a row’);
--end;
OUTPUT:
ERROR at line 1:
ORA-20001: you cannot delete a row
ORA-06512: at “SCOTT.del1”, line 2 k/
e.t
ORA-04088: error during execution of trigger ‘SCOTT.del1’
ub
et
UPDATE:
cs
--begin
tp
--end;
OUTPUT:
ERROR at line 1:
ORA-20001: you cannot update a row
ORA-06512: at “SCOTT.upd1”, line 2
ORA-04088: error during execution of trigger ‘SCOTT.upd1’
RESULT:
Thus the usage of trigger were studied and executed in RDBMS.
http://csetube.tk/
EX NO: 5 Date:
PROCEDURES AND FUNCTIONS
AIM:
To study and execute the procedures and functions in PL/SQL.
PROCEDURES:
k/
A procedure has two parts namely, specification and body. The procedure
e.t
specification begins with keyword procedure and ends with procedure name or parameter list. The
ub
procedure body begins with keyword is and ends with the keyword end. It can also include
et
declarative, executable and exceptional parts with in the keywords are and end. Syntax to execute a
cs
FUNCTIONS:
A function is a subprogram that computes a value. The syntax for creating a function is
given below.
create or replace function <function_name> [argument]
return datatype is
(local declaration)
begin
(executable statements)
[exception]
(exception handlers)
end;
http://csetube.tk/
EX NO: 5 Date:
where arguments can be in, out or inout.
Similar to a procedure, a function also has two parts namely, the function specification and the
function body. The function specification begins with the keyword function and ends with the return
clause. The function body begins with the keyword is and ends with the keyword end. A PL/SQL
block can also be included in a function body.
n number;
et
x number;
cs
begin
://
n:=&n;
tp
x:=factorial(n);
ht
OUTPUT
SQL>/
Enter value for n: 5
Old 5:n:=&n;
New 5:n:=5;
The factorial of 5 is 120
PL/SQL procedure successfully completed.
RESULT:
Thus the procedures and functions were studied and executed in PL/SQL.
http://csetube.tk/
EX NO: 6 Date:
EMBEDDED SQL
AIM:
To write JAVA program to implement embedded SQL.
ALGORITHM:
Roll no Number
Name Text
Dept Text
Marks Number
k/
e.t
3. Open MS.Access and then select Blank Database. In the File new database dialog give the
ub
4. Select create table in design view option from the dialog box that appears.
://
http://csetube.tk/
EX NO: 6 Date:
PROGRAM:
import java.io.*;
import java.sql.*;
public class jdeg
{
Public static void main(String args[])throws IOExcepyion
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String rollno,nam,dep,mark;
System.out.println(“Enter the values(rno,name,dept,marks)to insert into table”);
rollno=br.readLine();
nam=br.readLine();
dep=br.readLine();
mark=br.readLine();
try k/
e.t
{
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
ub
Connection con=DriverManager.getConnection(“jdbc:odbc:stu”);
et
’”+dep+”’,’”+mark+”’)”);
://
System.out.println();
ht
System.out.println();
System.out.println(“RNO\tNAME\tDEPT\tMARKS”);
while(rs.next())
{
System.out.println(rs.getString(“rno”)+”\t”);
System.out.println(rs.getString(“name”)+”\t”);
System.out.println(rs.getString(“dept”)+”\t”);
System.out.println(rs.getString(“marks”)+”\t”);
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
http://csetube.tk/
EX NO: 6 Date:
OUTPUT:
D:\jdk1.3\bin>edit jdeg.java
D:jdk1.3\bin>javac jdeg.java
D:jdk1.3\bin>java jdeg
D:jdk1.3\bin>
cs
://
tp
ht
RESULT:
Thus a JAVA program to implement embedded SQL has been executed successfully.
http://csetube.tk/
EX NO: 7 Date:
DATABASE DESIGN USING NORMALIZATION AND
E-R DIAGRAM
AIM:
To design database using normalization and E-R Diagram.
PROCEDURE:
Create a type ‘Address’ to represent composite attribute.
1. Create the table.
2. Insert the value in the table.
3. Draw the E-R diagram for the table.
4. Convert the given table to the normalized form.
k/
To convert a table to 1 NF remove all the multi valued & composite attributes
e.t
from the table.
ub
et
on only a part of the key and not on the whole key. Place them in a different
ht
table.
ii. Group the remaining attributes.
NORMALIZING THE TABLE TO 1 NF:
http://csetube.tk/
EX NO: 7 Date:
SQL>desc en2;
1 NF
emp 1 emp2
Table created.
://
tp
Table altered.
http://csetube.tk/
EX NO: 7 Date:
Ep1
eno ename
Ep2
pno pname
Ep3
eno Pno hours
k/
e.t
ub
Table created.
tp
ht
http://csetube.tk/
EX NO: 7 Date:
Empdept
Eno ename Sal dno dname
3 NF
Ed1
Eno Ename sal dno
Ed2
Dno Dname
k/
e.t
ub
et
cs
://
tp
ht
RESULT:
Thus the database was designed using E-R diagram and Normailization
http://csetube.tk/
EX NO: 8 Date:
AIM:
To develop a library information system using Oracle as a back end (data base)and
Microsoft Visual Basic as a front end.
PROCEDURE:
1.Create a book and issue database with the following fields in Oracle namely
Bid,Bname,Author,Price,noofcopiesavailable and Bid,Bname,Author,card
number,stuname,dateofreturn respectively and insert some record into the database.
2.Design the corresponding form with labels,text boxes and command buttons.
k/
e.t
Form1 bookdetails
ub
Form2 issuedetails
et
3.Create the back with the front end using DAO method by creating a dsn as follows
cs
b.In Create New Data Source dialog box,select “Microsoft ODBC for
ORACLE” and click finish button.
c.Give a suitable data source name,user name and server name.
http://csetube.tk/
EX NO: 8 Date:
TABLE DESIGN:
NAME TYPE
BID NIMBER(6)
BNAME VARCHAR2(30)
AUTHOR VARCHAR2(20)
PRICE NUMBER(8,2)
NO OF COPIES NUMBER(3)
AVAILABLE
k/
e.t
Table Name 2:Issue
ub
et
cs
://
BID NUMBER(6)
tp
BNAME VARCHAR2(30)
ht
AUTHOR VARCHAR2(20)
CARDNUMBER VARCHAR2(8,2)
STUNAME VARCHAR2(8,2)
DATEOFRETURN NUMBER(6)
http://csetube.tk/
EX NO: 8 Date:
k/
e.t
ub
et
cs
://
tp
ht
http://csetube.tk/
EX NO:8 Date:
k/
e.t
ub
et
cs
://
tp
ht
FORM 1:
Dim DB As Database
Dim RS As recordset
http://csetube.tk/
EX NO: 8 Date:
Private Sub CLEAR_click()
Text1.text=””
Text2.text=””
Text3.text=””
Text4.text=””
Text5.text=””
End Sub
Text4.text=RS(3)
et
Text5.text=RS(4)
cs
End If
://
End Sub
tp
ht
http://csetube.tk/
EX NO: 8 Date:
Private Sub MOVEFIRST_Click()
RS.MOVEFIRST
Text1.text=RS(0)
Text2.text=RS(1)
Text3.text=RS(2)
Text4.text=RS(3)
Text5.text=RS(4)
End Sub
Private Sub SEARCH_Click()
1=InputBox(“ENTER THE BID”,”FIND”)
RS.FindFirst”[BID]-”&I
If RS.NoMatch Then
MsgBox”no such records”
Else
RS.MOVEFIRST
Text1.text=RS(0) k/
e.t
Text2.text=RS(1)
Text3.text=RS(2)
ub
Text4.text=RS(3)
et
Text5.text=RS(4)
cs
End Sub
://
If Val(Text5.Text)>=1 Then
ht
Form2.Show
Else
MsgBox”NO BOOKS AVAILABLE”
End If
End Sub
FORM2:
Dim DB As Database
Dim RS As recordset
http://csetube.tk/
EX NO: 8 Date:
Private Sub ISSUE_Click()
RS.AddNew
RS(0)=Text1.Text
RS(1) =Text2.Text
RS(2)=Text3.Text
RS(3)=Text4.Text
RS(4)=Text5.Text
RS(5)=Text6.Text
RS.UPDATE
RS.MOVELAST
Form1.Text5=val(Form1.Text5)-1
End Sub
Private Sub MOVELAST_Click()
RS.MOVELAST
Text1.text=RS(0)
Text2.text=RS(1) k/
e.t
Text3.text=RS(2)
Text4.text=RS(3)
ub
Text5.text=RS(4)
et
End Sub
cs
://
RS.MoveNext
ht
IfRS.EOF Then
MsgBox”no more records”
Else
Text1.text=RS(0)
Text2.text=RS(1)
Text3.text=RS(2)
Text4.text=RS(3)
Text5.text=RS(4)
End If
End Sub
http://csetube.tk/
EX NO: 8 Date:
Text1.text=RS(0)
Text2.text=RS(1)
Text3.text=RS(2)
Text4.text=RS(3)
Text5.text=RS(4)
End If
End Sub
Form1.Show
cs
Form2.Hide
://
End Sub
tp
ht
RESULT:
Thus library information system was developed in Visual Basic.
http://csetube.tk/
EX NO: 9 Date:
DESIGN AND IMPLEMENTATION OF BANKING SYSTEM
AIM:
To develop a banking system using Oracle as s back end(data base) and Microsoft Visual
basic6.0 as a front end.
PROCEDURE:
2.design the corresponding form with labels,text boxes and command buttons.
Form1customer details
Form2withdraw
Form3deposit k/
e.t
ub
3.Create the back with the front end using DAO method by creating a dsn as follows
et
b.In Create New Data Source dialog box,select “Microsoft ODBC for
ht
http://csetube.tk/
EX NO: 9 Date:
TABLE DESIGN:
NAME TYPE
ACNO NUMBER(6)
NAME VARCHAR2(30)
ADDRESS VARCHAR2(20)
BALANCE NUMBER(8,2)
FORM 1:
k/
e.t
Dim DB As Database
ub
Dim RS As recordset
et
cs
Text1.text=RS(0)
Text2.text=RS(1)
Text3.text=RS(2)
Text4.text=RS(3)
End Sub
http://csetube.tk/
EX NO: 9 Date:
Private sub DELETE_Click()
RS.DELETE
MsgBox”the record is deleted”
RS.MoveNext
IfRS.EOF Then
MsgBox”no more records”
Else
Text1.text=RS(0)
Text2.text=RS(1)
Text3.text=RS(2)
Text4.text=RS(3)
End If
End Sub
RS .MoveFirst
cs
Text1.Text=RS(0)
://
Text2.Text=RS(1)
tp
Text3.Text=RS(2)
ht
Text4.Text=RS(3)
End Sub
http://csetube.tk/
EX NO: 9 Date:
Private Sub LAST_Click()
RS. MoveLast
Text1.text=RS(0)
Text2.text=RS(1)
Text3.text=RS(2)
Text4.text=RS(3)
End Sub
End Sub
et
RS.Move Previous
://
If RS.EOF Then
tp
Else
Text1.text=RS(0)
Text2.text=RS(1)
Text3.text=RS(2)
Text4.text=RS(3)
EndIf
End Sub
http://csetube.tk/
EX NO: 9 Date:
Private Sub FIND_Click()
1=InputBox(“ENTER THE ACNO”,”FIND”)
rs.FindFirst”[ACNO]=”&I
If rs.NoMatch Then
MsgBox”no such records”
Else
Text1.text=RS(0)
Text2.text=RS(1)
Text3.text=RS(2)
Text4.text=RS(3)
EndIf
End Sub
Form3.Show
et
End Sub
cs
://
FORM 2:
tp
ht
End
http://csetube.tk/
EX NO: 9 Date:
FORM 3:
k/
e.t
ub
et
cs
://
tp
ht
http://csetube.tk/
EX NO: 9 Date:
k/
e.t
ub
et
cs
://
tp
ht
http://csetube.tk/
EX NO: 9 Date:
k/
e.t
ub
et
cs
://
tp
ht
RESULT:
http://csetube.tk/
EX NO: 10 Date:
DESIGN AND IMPLEMENTATION OF PAYROLL PROCESSING SYSTEM
AIM:
To develop an employee payroll system using Oracle as a back end (database) and Microsoft
Visual Basic6.0 as a front end.
PROCEDURE:
2.Design the corresponding form with labels,text boxes and command buttons.
Form1Employee Payroll
k/
3.Create the back with the front end using DAO method by creating a DSN as
e.t
follows,
ub
b.In Create New Data Source dialog box,select “Microsoft ODBC for
://
.
ht
http://csetube.tk/
EX NO:10 Date:
TABLE DESIGN:
Table Name :Employee
NAME TYPE
EMPNO NUMBER(6)
EMPNAME VARCHAR2(30)
DESIGNATION VARCHAR2(20)
DA NUMBER(10)
HRA NUMBER(10)
ADDRESS VARCHAR2(20)
TA NUMBER(10)
PF NUMBER(10)
BASICPAY NUMBER(8,2)
k/
e.t
LOAN.Text=adodc1.Recordset.Fields(9)
ADV.Text= adodc1.Recordset.Fields(10)
ub
TD.Text=adodc1.Recordset.Fields(11)
et
GP.Text=adodc1.Recordset.Fields(12)
cs
NP.Text=adodc1.Recordset.Fields(13)
://
End Sub
tp
ht
PROGRAM TO VIEW:
Private sub view_Click()
Dim a As Integer
On Error Go To err
a=InputBox(“enter the empno”)
Adodc1.Recordset.MOVEFIRST
While Not Adodc1. Recordset.EOF
If Adodc1.Recordset.Fields(0)=a Then
fillt 1
Exit Sub
End If
Adodc1.Recordset.MOVENEXT
Wend
err:
MsgBox(“record doesnot exist”)
End Sub
http://csetube.tk/
EX NO: 10 Date:
Private sub MOVENEXT_Click()
Adodc1.Recordset.MOVENEXT
End Sub
PROGRAM TO SAVE:
Private sub save_Click()
Adodc1.Recordset.Update
NAME1.Enabled=False
NO.Enabled=False
DESIG.Enabled=False
B1.Enabled=False
HRA.Enabled=False k/
e.t
DA.Enabled=False
ub
OA.Enabled=False
et
TA.Enabled=False
cs
LOAN.Enabled=False
://
ADV.Enabled=False
tp
TD.Enabled=False
ht
GP.Enabled=False
PF.Enabled=False
NP.Enabled=False
add.Enabled= True
del.Enabled= True
BASIC.Enabled= True
edit.Enabled=True
End Sub
Fill function
Public sub fillt()
NO.Text=adodc1.Recordset.Fields(0)
NAME.Text= adodc1.Recordset.Fields(1)
DESIG.Text=adodc1.Recordset.Fields(2)
MONYH.Text=adodc1.Recordset.Fields(14)
B1.Text=adodc1.Recordset.Fields(3)
http://csetube.tk/
EX NO: 10 Date:
DA.Text=adodc1.Recordset.Fields(4)
HRA.Text= adodc1.Recordset.Fields(5)
OA.Text=adodc1.Recordset.Fields(6)
TA.Text=adodc1.Recordset.Fields(7)
PF.Text=adodc1.Recordset.Fields(8)
LOAN.Text=adodc1.Recordset.Fields(9)
ADV.Text= adodc1.Recordset.Fields(10)
PROGRAM TO ADD:
OA.Enabled= True
et
TA.Enabled= True
cs
LOAN.Enabled= True
://
ADV.Enabled= True
tp
TD.Enabled= True
ht
GP.Enabled= True
PF.Enabled= True
NP.Enabled= True
save. Enabled=True
NO.SetFocus
MsgBox”new record is added”
add. Enabled=False
del.Enabled=False
BASIC. Enabled=False
edit. Enabled=False
End Sub
http://csetube.tk/
EX NO: 10 Date:
PROGRAM TO CALCULATE ALLOWANCES:
Dim a As Integer
cs
Adodc1.Recordset.MOVEFIRST
tp
If Adodc1.Recordset.Fields(0)=a Then
Fillt
Exit Sub
End If
Adodc1.Recordset.MOVENEXT
Wend
MsgBox”record modify successfully”
add.Enabled=False
del.Enabled=False
BASIC. Enabled=False
edit. Enabled=False
End Sub
http://csetube.tk/
EX NO: 10 Date:
End Sub
et
cs
Adodc1.Recordset.MOVEFIRST
tp
End Sub
ht
http://csetube.tk/
EX NO:10 Date:
Adodc1.Recordset.MOVENEXT
Wend
MsgBox”record deleted”
err:
MsgBox”record does not exists”
End Sub
Private sub edit_Click()
Form1.Caption=”modify operation”
Adodc1.Recordset.Update
NAME1.Enabled=True
NO.Enabled= True
DESIG.Enabled= True
B1.Enabled= True
HRA.Enabled= True
DA.Enabled= True k/
e.t
OA.Enabled= True
ub
TA.Enabled= True
et
LOAN.Enabled= True
cs
ADV.Enabled= True
://
TD.Enabled= True
tp
GP.Enabled= True
ht
PF.Enabled= True
NP.Enabled= True
save. Enabled=True
NO.SetFocus
http://csetube.tk/
EX NO:10 Date:
OUTPUT:
k/
e.t
ub
et
cs
://
tp
ht
RESULT:
Thus employee payroll processing system was developed in visual basic
http://csetube.tk/