+ All Categories
Home > Documents > Dbms Lab Manual

Dbms Lab Manual

Date post: 12-Dec-2014
Category:
Upload: pristuniversity
View: 55 times
Download: 0 times
Share this document with a friend
Popular Tags:
30
TABLE OF CONTENTS S.No Topic Page No 1 Lab Objectives 01 2 Introduction 03 3 DDL Commands 04 4 DML and DCL Commands 07 5 High Level Language Extension with Cursors 14 6 High Level Language Extension with Trigger 18 7 Procedures 23 8 Design and Implementation of Pay roll processing 27
Transcript
Page 1: Dbms Lab Manual

TABLE OF CONTENTS

S.No Topic Page No

1

Lab Objectives

01

2

Introduction

03

3

DDL Commands

04

4

DML and DCL Commands

07

5

High Level Language Extension with Cursors 14

6

High Level Language Extension with Trigger 18

7 Procedures 23

8

Design and Implementation of Pay roll processing

27

Page 2: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

1

LAB OBJECTIVES

A vast majority of the software applications being built use some kind of a data store

mechanism to permanently store the data generated/used by the software. Database

management systems are complex software systems that provide a wide variety of

functionality for users to structure, organize and access data quickly and efficiently.

Database systems have been there since the early 1970‟s but have grown in complexity

and size. Relational database management systems use relational algebra as the basis for

representation of data. RDBMS as relational database management systems are the most

popular and widely used DBMS in the market place.

In this lab, you would be exposed to one popular RDBMS. The broad one line objective

of the lab is to get familiar with the functionality and support provided by commercially

popular RDBMS and understand how to use it to meet your data storage and organization

requirements.

Detailed objectives of the lab are:

You learn SQL (Structured Query Language) which would provide functionality

to:

o Learn how to create tables which are fundamental storage blocks of data.

o Learn how to place constraints on data that is entered on tables to ensure

data integrity.

o Learn how to add, change and remove data from tables.

o Learn how to select a subset of the data you want to see from the

collection of tables and data.

o Learn how to combine table and group multiple rows of data in table.

Page 3: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

2

You learn PL/SQL which would provide the ability to do iterative programming

at database level to:

o Write programming blocks with conditionals, assignments, loops, etc

o Exception Handling.

o Transaction oriented programs

o Stored procedures, functions, packages.

o Cursors which would allow row wise access of data.

o Triggers which would allow you define pre and post actions when

something changes in the database tables.

At the end of the lab, you should be comfortable using any popular RDBMS for data

access and updating and should be comfortable writing PL/SQL programs at database

level using Oracle.

Page 4: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

3

INTRODUCTION

RDBMS is one of the most widely used pluggable software components in most

enterprise software applications. Though RDBMS applications have been there since the

early 1970s, they have improved tremendously in terms of their features, the size of data

they can hold, and the complexity over the last 20 years.

Oracle is one of the very widely used commercial RDBMS systems and at this point is

the market leader as far as RDBMS is concerned. Oracle9i is RDBMS software which

supports SQL – 1999. It also supports programming language extension to SQL called

PL/SQL which is Oracle proprietary and is very popular to do program development at

the database server level. Other popular DBMS software like Sybase and SQL Server

support their own programming extensions to SQL – 1999.

Page 5: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

4

AIM:

To perform the following DDL commands in SQL.

*Create a table.

*Alter the table

*Rename the table.

*Truncate the table.

*Drop the table.

PROCEDURE:

# To create a table of name, id, designation and dept of employee.

# Insert the values into table and the details are to be declared.

#Same as the above procedure alter, rename, truncate and drop the table in

Employee.

COMMANDS:

SQL> create table employee(empno number(15),ename char(15),designation

char(15),deptno number(15));

Table created.

SQL> desc employee;

Name Null? Type

------------------------------- -------- -------------------

EMPNO NUMBER(15)

ENAME CHAR(15)

DESIGNATION CHAR(15)

DEPTNO NUMBER(15)

SQL> insert into employee values(500,'Ganesh','manager',1);

1 row created.

EX.NO:01 DDL COMMANDS

Page 6: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

5

SQL> insert into employee values(501,'Vignesh','as manager',2);

1 row created.

SQL> select * from employee;

EMPNO ENAME DESIGNATION DEPTNO

--------- --------------- ---------------------- -----------------

500 Ganesh manager 1

501 Vignesh as manager 2

SQL> rename employee to best1;

Table renamed.

SQL> desc best1;

Name Null? Type

------------------------------- -------- ----

EMPNO NUMBER(15)

ENAME CHAR(15)

DESIGNATION CHAR(15)

DEPTNO NUMBER(15)

SQL> alter table best1 add(bonus number(15));

Table altered.

SQL> desc best1;

Name Null? Type

------------------------------- -------- -----------------

EMPNO NUMBER(15)

ENAME CHAR(15)

DESIGNATION CHAR(15)

DEPTNO NUMBER(15)

BONUS NUMBER(15)

SQL> select * from best1;

EMPNO ENAME DESIGNATION DEPTNO BONUS

--------- --------------- ---------------------- ------------- -------------

500 Ganesh manager 1

501 Vignesh as manager 2

Page 7: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

6

SQL> create view eno as select * from best1;

View created.

SQL> desc eno;

Name Null? Type

------------------------------- -------- -----------------

EMPNO NUMBER(15)

ENAME CHAR(15)

DESIGNATION CHAR(15)

DEPTNO NUMBER(15)

BONUS NUMBER(15)

SQL> drop table best1;

Table dropped.

RESULT:

Thus the commands have been performed and executed successfully.

Page 8: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

7

AIM:

To perform the following DML and DCL commands in SQL.

*Insert.

*Update.

*Delete.

PROCEDURE:

# Create a table with „employee‟ with empid, empname, designation,

dep.no and salary as attributes.

# Insert the value into the table.

# Update the value into the table in employee.

# Delete the value whatever we need.

# Perform the grouping function.

COMMANDS:

Data Manipulation Language (DML)

SQL> create table emp2(eno number(5),ename char(8),job char(9),mgrhiredate char(15),sal

number(6),deptno number(4),commission number(4));

Table created.

SQL> insert into emp2 values (1000,'arun','clerk','30-sep-09', 2300, 30, 1000);

1 row created.

EX.NO:02 DML AND DCL COMMANDS

Page 9: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

8

SQL> insert into emp2 values(1001,'arjun','manager','24-feb-81',1500,35,1075);

1 row created.

SQL> insert into emp2 values(1002,'uma','salesman','25-feb-08'1501,36,1045);

1 row created.

SQL> insert into emp2 values(1003,'sathiya','salesman','25-mar-09',1500,38,2000);

1 row created.

SQL> insert into emp2 values(1004,'sharmila','salesman','30-apr-11',1500,39,2001);

1 row created.

SQL> select*from emp2;

EMP2 ENAME JOB MGRHIRE DATE SAL DEPTNO COMMISSION

----------- --------------- ------------ --------------------- --------- -------------- ------------------

1000 arun clerk 30-sep-09 2300 30 1000

1001 arjun manager 24-feb-81 1500 35 1075

1002 uma salesman 25-feb-08 3000 45 1045

1003 sathiya salesman 25-mar-09 5500 20 2000

1004 sharmila salesman 30-apr-11 4000 40 2001

SQL> create table dept(deptno number(3),dname char(10),location char(15));

Table created.

SQL> insert into dept values(30,'research','dallas');

1 row created.

SQL> insert into dept values(40,'accounting','australia');

SQL> desc dept;

NAME NULL? TYPE

---------------------------------------------------------

DEPTNO NUMBER(3)

DNAME CHAR(10)

LOCATION CHAR(15)

SQL> select*from dept;

Page 10: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

9

DEPTNO DNAME LOCATION

--------------------------------------------------------------------------

30 research dallas

40 accounting australia

SQL> delete from dept where deptno=2;

0 row deleted.

SQL> select*from dept;

DEPTNO DNAME LOCATION

---------------------------------------------------------------------------

30 research dallas

40 accounting australia

SQL> delete * from dept;

2 rows deleted.

Data Control Language (DCL)

Data Control Language Statements are used to grant privileges on tables, views,

sequences, synonyms, procedures to other users or roles.

The DCL statements are

GRANT : Use to grant privileges to other users or roles.

REVOKE : Use to take back privileges granted to other users and roles.

Privileges are of two types:

System privileges

Object privileges

Page 11: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

10

System Privileges are normally granted by a DBA to users.

Examples: CREATE SESSION, CREATE TABLE, CREATE USER etc.

Object privileges means privileges on objects such as tables, views, synonyms,

procedure. These are granted by owner of the object.

Object Privileges are

ALTER Change the table definition with the ALTER TABLE statement.

DELETE Remove rows from the table with the DELETE statement.

Note: You must grant the SELECT privilege on the table along with

the DELETE privilege.

INDEX Create an index on the table with the CREATE INDEX statement.

INSERT Add new rows to the table with the INSERT statement.

REFERENCES Create a constraint that refers to the table. You cannot grant this privilege to a

role.

SELECT Query the table with the SELECT statement.

UPDATE Change data in the table with the UPDATE statement.

Note: You must grant the SELECT privilege on the table along with

the UPDATE privilege.

GRANT

Grant is use to grant privileges on tables, view, procedure to other users or roles

Examples:

Suppose you own emp table. Now you want to grant select,update,insert privilege on this

table to other user “uma”. grant select, update, insert on emp to uma;

Suppose you want to grant all privileges on emp table to uma. Then

grant all on emp to uma;

Page 12: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

11

Suppose you want to grant select privilege on emp to all other users of the database. Then

grant select on emp to public;

Suppose you want to grant update and insert privilege on only certain columns not on all

the columns then include the column names in grant statement. For example you want to

grant update privilege on ename column only and insert privilege on empno and ename

columns only. Then give the following statement

grant update (ename),insert (empno, ename) on emp to uma;

To grant select statement on emp table to uma and to make uma be able further pass on

this privilege you have to give WITH GRANT OPTION clause in GRANT statement like

this.

grant select on emp to uma with grant option;

REVOKE Use to revoke privileges already granted to other users.

For example to revoke select, update, insert privilege you have granted to Sami then give

the following statement.

revoke select, update, insert on emp from uma;

To revoke select statement on emp granted to public give the following command.

revoke select on emp from public;

To revoke update privilege on ename column and insert privilege on empno and ename

columns give the following revoke statement.

revoke update, insert on emp from uma;

Note: You cannot take back column level privileges. Suppose you just want to take

back insert privilege on ename column then you have to first take back the whole insert

privilege and then grant privilege on empno column.

Page 13: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

12

ROLES

A role is a group of Privileges. A role is very handy in managing privileges, particularly

in such situation when number of users should have the same set of privileges.

For example you have four users: arun, sharmila, sathiya,uma in the database. To these

users you want to grant select, update privilege on emp table, select, delete privilege on

dept table. To do this first create a role by giving the following statement

create role clerks;

Then grant privileges to this role.

grant select,update on emp to clerks;

grant select,delete on dept to clerks;

Now grant this clerks role to users like this

grant clerks to arun, sharmila, sathiya,uma;

Now arun, sharmila,sathiya and uma have all the privileges granted on clerks role.

Suppose after one month you want grant delete on privilege on emp table all these users

then just grant this privilege to clerks role and automatically all the users will have the

privilege.

grant delete on emp to clerks;

If you want to take back update privilege on emp table from these users just take it back

from clerks role.

revoke update on emp from clerks;

To Drop a role

Drop role clerks;

Page 14: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

13

LISTING INFORMATION ABOUT PRIVILEGES

To see which table privileges are granted by you to other users.

SELECT * FROM USER_TAB_PRIVS_MADE

To see which table privileges are granted to you by other users

SELECT * FROM USER_TAB_PRIVS_RECD;

To see which column level privileges are granted by you to other users.

SELECT * FROM USER_COL_PRIVS_MADE

To see which column level privileges are granted to you by other users

SELECT * FROM USER_COL_PRIVS_RECD;

To see which privileges are granted to roles

SELECT * FROM USER_ROLE_PRIVS;

RESULT:

Thus the commands have been performed and executed successfully.

Page 15: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

14

AIM:

To write a PL/SQL procedure for the implementation of cursors in DBMS.

PROCEDURE:

# Create table „tmp‟ with empno, empname, empsalary as attributes.

# Create another table „emp2‟ with eno, ename, salary as attributes.

#The values of ceno, cename and salary of cursor inserted into tables.

# Select all column of emp2 to view data.

EX.NO:03 HIGH LEVEL LANGUAGE EXTENSION WITH CURSORS

Page 16: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

15

COMMANDS:

SQL> create table temp(tname varchar(10),tno number(10),tsalary number(10));

Table created.

SQL> desc temp;

Name Null? Type

----------------------------------------- -------- ----------------------------

TNAME VARCHAR2(10)

TNO NUMBER(10)

TSALARY NUMBER(10)

SQL> create table emp1(ename varchar(10),eno number(10),esalary number(10));

Table created.

SQL> desc emp1;

Name Null? Type

----------------------------------------- -------- ----------------------------

ENAME VARCHAR2(10)

ENO NUMBER(10)

ESALARY NUMBER(10)

SQL> insert into emp1 values('ram',01,10000);

1 row created.

SQL> insert into emp1 values('lakshman',02,20000);

1 row created.

SQL> insert into emp1 values('rama',03,14000);

1 row created.

SQL> insert into emp1 values('guna',04,13000);

1 row created.

SQL> insert into emp1 values('jana',05,14000);

1 row created.

Page 17: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

16

SQL> select * from emp1;

ENAME ENO ESALARY

---------- ---------- --------------------

ram 1 10000

lakshman 2 20000

rama 3 14000

guna 4 13000

jana 5 14000

SQL> declare

2 cursor c1 is select ename,eno,esalary

3 from emp1

4 order by esalary desc;

5 cename varchar(20);

6 ceno number(10);

7 cesalary number(10);

8 begin

9 open c1;

10 loop

11 fetch c1 into cename,ceno,cesalary;

12 exit when (c1%notfound)or(c1%rowcount>5);

13 insert into temp values(cename,ceno,cesalary);

14 commit;

15 end loop;

16 close c1;

17 end;

18 /

PL/SQL procedure was successfully completed.

SQL> desc temp;

Name Null? Type

----------------------------------------- -------- ----------------------------

TNAME VARCHAR2(10)

TNO NUMBER(10)

TSALARY NUMBER(10)

Page 18: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

17

SQL> select * from temp;

TNAME TNO TSALARY

---------------- ----------- ----------------

lakshman 2 20000

rama 3 14000

guna 4 14000

jana 5 13000

ram 1 10000

RESULT:

Thus the program has been performed and executed successfully.

Page 19: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

18

AIM:

To write a PL/SQL procedure for the implementation of TRIGGER in SQL.

PROCEDURE:

# Create table „Bookdetails‟ with is bno, bname, authorname, publisher,

pub-year as attributes.

# Create another table „operation table‟ with table name, sys-data and

users as attributes.

# Insert values into table „Book Details‟ in same order as attributes.

# Insert „Sample trigger‟.

# Create trigger „sample trigger‟ which will active only for deletion or

updation of roll on class table.

# Execute the program.

EX.NO:04 HIGH LEVEL LANGUAGE EXTENSION WITH TRIGGER

Page 20: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

19

COMMANDS:

SQL>create table emp100(no number(5),name char(10),sal number(5));

Table Created

SQL>insert into emp100 values(&no,'&name',&sal);

enter value for no:1

enter value for name: varad

enter for sal: 15000

old : insert into emp100 values(&no,'&name',&sal)

new 1: insert into emp100 values(1,'varad',15000)

1 row created

SQL>/

enter value for no:2

enter value for name:ram

enter value for sal:20000

old : insert into emp100 values(&no,'&name',&sal)

new 1: insert into emp100 values(2,'varadan',15000)

1 row created

SQL>select*from emp100;

NO NAME SAL

------- ----- -------------------------------

1 varad 150000

2 varadan 150000

SQL>create table oper100(oper char(10),tab char(10),sys date, user char(10));

Table Created

SOL>create trigger tri101 after insert or delete or update on emp 100

2 begin

3 if insert then

4 insert into oper100 values('insert',‟employee',sysdate,user);

5 end if;

6 if deleting then

7 insert into oper100('delete',‟employee',sysdate,user);

8 end if

9 if updating then

Page 21: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

20

10 insert into oper100 values('update‟,‟employee',sysdate,user);

11 end if;

12 end;

13 /

trigger created.

SQL>insert into emp100 values(055,'ddddd',1000);

1 row created.

SQL>delete from emp100 where no=2;

2 rows deleted.

SQL>select*from emp100;

NO NAME SAL

---- ---- --------

1 varad 15000

2 ddddd 1000

2 rows Selected...

SQL>selected*from oper100;

OPER TAB SYS USERS

------ ------ ------- ---------

insert employee 01-jan 2cs66

insert employee 01-jan 2cs66

delete employee 01-jan 2cs66

SQL>created table emp17(eno number(5),deptno number(5),sal number(10));

Table Created

SQL>insert into emp17 values(&eno,&deptno,&sal);

enter value for eno:001

enter value for deptno:22222

enter value for sal:20000

old : insert into emp17 values(&no,&deptno,&sal)

new 1: insert into emp17 values(001,'22222',20000)

1 row created

SQL>/

enter value for eno:002

enter value for deptno:33333

enter value for sal:30000

old : insert into emp17 values(&eno,&deptno,&sal)

Page 22: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

21

new 1: insert into emp17 values(002,'33333',30000)

1 row created

SQL>select * from emp17;

ENO DEPTNO SAL

---- -- --------------- -----------

1 22222 20000

2 33333 30000

SQL>create table depp(dname char(5),deptno number(10));

Table created..

SQL>insert into depp values('&name',&deptno);

enter value for name:cseenter value for deptno:25

old : insert into depp values('&name',&deptno)

new 1: insert into depp values('cse',25)

1 row created

SQL>/

enter value for name:it

enter value for deptno:28

old : insert into depp values('&name',&deptno)

new 1: insert into depp values('it',28)

1 row created

SQL>select*from depp;

DNAME DEPT

----- -------------

cse 25

it 28

SQL>create trigger tr4 after delete or update of

2 depton dept for each row

3 begin

4 if deleting then

5 update emp17 set emp17.dept=0 where

6 emp17.deptno=:old.deptno;

7 end if

8 if updating then

9 update emp17 set emp17.dept=:new.deptno

10 where emp17.deptno=:old.dept;

11 end if;

12 end;

13 /

Page 23: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

22

Trigger created.

SQL>update depp set deptno=500 where dname='cse';

1 row updated.

SQL>select*from depp;

DNAME DEPTNO

----- -----------------

cse 500

it 28

SQL>select*from depp;

DNAME DEPTNO

----- ------------------------

cse 25

it 28

RESULT:

Thus the program has been performed and executed successfully.

Page 24: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

23

AIM:

To implement the concepts of procedures in SQL.

PROCEDURE:

# Create table emp-pro1 with empid, empname, designation and deptno as

attributes.

# Insert the values as per attributes.

# Create procedure Del-emp(eid).

# Delete the record from table emp-pro1 where eid-empid.

# If it is not there declare invalid.

# Create value emp-pro 2 with empid, name , designation and salary.

# Insert the values.

# Create second procedure.

# If condition is not true then display invalid.

# Execute the program.

EX.NO:05 PROCEDURES

Page 25: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

24

COMMANDS:

SQL> create table emp101(empno number(15),ename char(15),designation

char(15),deptno number(15));

table created

SQL>desc emp101

name Null? type

--------------------------------------------

EMPNO NUMBER(15)

EMPNAME CHAR(15)

DESIGNATION CHAR(15)

DEPTNO NUMBER(15)

SQL>insert into101 values(500,'Ramkumar','manager',2);

1row created.

SQL>insert into emp101 values(501,'varadan','as manager',3);

1 row created

SQL>select*from emp101;

EMPNO ENAME DESIGNATION DEPTNO

---------------------------------------------

500 Ramkumar manager 1

501 Varadan as manager 2

SQL>create or replace procedure del_emp101(empid in number)as

2 begin

3 delete from emp101 where no=empid;

4 if SQL%NOTFOUNDthen

5 raise_application_error(-20011,'invalid application number');

6 endif;

7 end del_emp101;

8 /

Procedure created.

SQL>execute del_emp101(1);

PL/SQLprocedure successfully completed.

SQL>select*from emp101;

EMPNO ENAME DESIGNATION DEPTNO

--------- ----------------------------------

501 Varadan as manager 2

/*PROCEDURE2*/

SQL>create table emp103(no number(5),name char(5),des char(5),sal number(10));

Table created.

SQL>select*from emp103;

NO NAME DESC SAL

-----------------------------

5 BALA 1000000

Page 26: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

25

SQL>create procedure sal_raise(eid in number,salin in number)as

2 begin

3 update emp103 set sal+salin where no=eid;

4 if SQL%NOTFOUNDthen

5 raise_application_error(-20500,'invalid emp number');

6 end if;

7 end sal_raise;

8/

Procedure created.

SQL>execute sal_raise(5,10000);

PL/SQL procedure successfully completed.

sql>select*from emp103;

NO NAME DES SAL

--------------------------------------------

5 BALA PILOT 1000000

SQL>create*from emp111;

ENO ENAME JOB SAL DNO

--------------------------------------

1 bala pilot 1000000 56

2 ram engg 2000000 45

SQL>create or replace package emp_mgnt as function emp111(eno number,ename

char,jod char,sal number,dno number)return number;

2 procedure p1(emp_id number,sal_incr number);

3 procedure p2(emp_id number);

4 end emp_mgnt;

/

Package created.

SQL>create or replace package body emp_mgnt as

2 function em111(eno number,ename char,job char,sal number,dno number)return

number is

3 begin

4 insert into em111 values(eno,ename,job,sal,dno);

5 return(eno);

6 end emp11;

7 procedure p1(emp_id in number,sal_incr in number)as

8 begin

9 update em11 setsal=sal+sal_incr where eno=emp_id;

10if SQL%NOTFOUND then

11raise_application_error(-2011,'invalid employee number:||to_char(emp_id));

12end if;

13end p1;

14procedure p2(emp_id in number)as

15begin

16delete from em11 where eno=emp_id;

17ifSQL%NOTFOUND then

18raise_application_error(-2011.'invalid employee number'||to_char(emp_id));

Page 27: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

26

19end if;

20endp2;

end emp_mgnt;

22/

Package body created.

SQL>execute emp_mgnt.p1(1,100000);

PL/SQLprocedure successfully completed.

SQL>execute emp_mgnt.p2(3);

PL/SQL procedure successfully completed.

SQL>select*from em11;

ENO ENAME JOB SAL DNO

---------------------------------------------------------

1 bala pilot 1000000 56

RESULT:

Thus the program has been performed and executed successfully.

Page 28: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

27

.

AIM:

To write a program for design and implementation of payroll processing.

PROCEDURE:

# Open visual basic for required details.

# Set table box, text box, command button and data for payroll processing.

# Write coding for details.

# Create database for payroll using oracle database.

# Create table in oracle.

# Connect visual basic with oracle database.

# Execute the visual basic program.

EX.NO:06 DESIGN AND IMPLEMENTATION OF PAYROLL PROCESSING

Page 29: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

28

PROGRAM:

Private Sub Command1_Click()

Adodc1.Recordset.AdNew

End Sub

Private Sub Command2_Click()

Adodc1.Recordset.Update

End Sub

Private Sub Command3_Click()

Adodc1.Recordset.EditMode

End Sub

Private Sub Command4_Click()

End

End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)

If KeyAscii=13 Then

Text2.SetFocus

End If

End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)

If KeyAscii=13 Then

Text3.SetFocus

End If

End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)

If KeyAscii=13 Then

Text4.Text=(Val(Text3.Text)*30)/100

Text5.Text=(Val(Text3.Text)*50)/100

Text6.Text=(Val(Text3.Text)*10)/100

Text7.Text=(Val(Text3.Text)*20)/100

Text8.Text=(Val(Text3.Text)+Val(Text4.Text)+Val(Text5.Text)+Val(Text6.Text)

Text9.Text=(Val(Text7.Text)

Text10.Text=(Val(Text8.Text)-Val(Text9.Text)

Command1.SetFocus

End If

End Sub

Page 30: Dbms Lab Manual

II YR/IV SEM DBMS LAB MANUAL

29

OUTPUT:

RESULT:

Thus the program has been performed and executed successfully.


Recommended