Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

S.No. Date Name of The Experiment No. Marks Obtained Signature

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 60

Page Marks

S.No. Date Name of the Experiment Signature


No. Obtained

Data Definition Language and


1 1
Data Manipulation Language
Database Language
2 7
with Constraints
3 Cursors 10

4 Triggers 15

5 Functions 19

6 Procedures 23

7 Embedded SQL 27

8 Entity Relationship Model 36

9 Payroll Process 41

10 Banking System 47

11 Library Information System 53

Average =

CONTENTS
Ex No. : 1

Aim:
To write SQL Queries using Data Definition Language and
Data Manipulation Language

DATA DEFINITION LANGUAGE

CREATE

Syntax:

SQL> create table <table_name> ( col_name1, datatype(size),………..);


SQL> create table <table_name> as select * from <source_table_name>

Queries:

SQL> create table employee(emp_id number(5),emp_name varchar2(10), salary


number(6));

Table created.

SQL> desc employee;


Name Null? Type
----------------------------------------- ---------- ----------------------------
EMP_ID NUMBER(5)
EMP_NAME VARCHAR2(10)
SALARY NUMBER(6)

SQL> create table emp as select * from employee;


Table created.

SQL> desc emp;


Name Null? Type
----------------------------------------- ---------- ----------------------------
EMP_ID NUMBER(5)
EMP_NAME VARCHAR2(10)
SALARY NUMBER(6)
ALTER:

Syntax:

SQL> alter table <table_name> add( new col_name1, datatype(size),………..);

Queries:

SQL> alter table employee add(experience number(2));

Table altered.
SQL> desc employee;

Name Null? Type


----------------------------------------- ---------- ----------------------------
EMP_ID NUMBER(5)
EMP_NAME VARCHAR2(10)
SALARY NUMBER(6)
EXPERIENCE NUMBER(2)

TRUNCATE:

Syntax:

SQL> truncate table <table_name>;

Queries:

SQL> truncate table employee;

Table truncated.

SQL> desc employee;


Name Null? Type
----------------------------------------- ---------- ----------------------------
EMP_ID NUMBER(5)
EMP_NAME VARCHAR2(10)
SALARY NUMBER(6)
EXPERIENCE NUMBER(2)

SQL> select * from employee;

no rows selected
DROP:

Syntax:

SQL>drop table <table_name>;

Queries:

SQL> drop table employee;

Table dropped.

SQL> desc employee;


ERROR:
ORA-04043: object employee does not exist

DATA MANIPULATION LANGUAGE

INSERT:

Syntax:
SQL> insert into <table_name> values(val1,……);
SQL> insert into <table_name> values(‘&col_name1’,……);

Queries:

SQL> insert into employee values(1006,'Ram',8500);


1 row created.

SQL> insert into employee values(&emp_no,'&name',&sal);


Enter value for emp_no: 1007
Enter value for name: ranjith
Enter value for sal: 15000
old 1: insert into employee values(&emp_no,'&name',&sal)
new 1: insert into employee values(1007,'ranjith',15000)

1 row created.

SQL> select * from employee;


EMP_ID EMP_NAME SALARY
------------- --------------------- -------------
1006 Ram 8500
1007 Ranjith 15000

SQL>
SELECT:

Syntax:

SQL> select *from <table_name>;

Queries:

SQL> select * from employee;

EMP_ID EMP_NAME SALARY


------------- --------------------- -------------
1006 Ram 8500
1007 Ranjith 15000

SQL>

UPDATE:

Syntax:

SQL> update <table_name> set col_name1=value where col_name2=value;

Queries:

SQL> update employee set Salary=&sal where emp_id=&emp_id;


Enter value for sal: 9200
Enter value for emp_id: 1006
old 1: update employee set experience=&exp where emp_id=&emp_id
new 1: update employee set experience=5 where emp_id=1006

1 row updated.

SQL> select * from employee;

EMP_ID EMP_NAME SALARY


------------- --------------------- -------------
1006 Ram 9200
1007 Ranjith 15000

SQL>
DELETE:

Syntax:

SQL> Delete from <table_name> where col_name=value;

Queries:

SQL> delete from employee where emp_id=1007;

1 row deleted.

SQL> select * from employee;

EMP_ID EMP_NAME SALARY


------------- --------------------- -------------
1006 Ram 9200

SQL>
Contents Max. Marks Marks Obtained
Design 20
Development 20
Queries & Execution 20
Viva Voce 20
Record 20
Total 100

Result:
Ex No. : 2

Aim:
To write SQL queries implementing constraints with DDL and DML

Syntax:

SQL> create table <table_name> ( col_name1, datatype(size),………..,


primary key(col_name1,….) );
SQL> create table <table_name> ( col_name1, datatype(size),………..,
unique(col_name1,….) );
SQL> create table <table_name> ( col_name11, datatype(size),………..,
foreign key(col_name11,….) as references
<source_table_name>(col_name21,… );
SQL> create table <table_name> (col_name1 datatype(size) not null,………);
SQL> create table <table_name>(col_name1 datatype(size),…..,
check(col_name1 in value));
SQL> create table <table_name>(col_name1 datatype(size),…..,
check(col_name1 not in value));
SQL> create table <table_name>(col_name1 datatype(size),…..,
check(col_name1 between value1 and value2));

Queries:

SQL> create table sample(id number(5), name varchar2(10), primary key(id));

Table created.

SQL> desc sample;


Name Null? Type
---------------- ----------------- ----------------------------
ID NOT NULL NUMBER(5)
NAME VARCHAR2(10)

SQL> create table sample(id number(5), name varchar2(10), unique(id));

Table created.
SQL> desc sample;
Name Null? Type
---------------- ----------------- ----------------------------
ID NUMBER(5)
NAME VARCHAR2(10)

SQL> create table samp (id number(5), name varchar2(10),


foreign key(id) references sample(id));

Table created.

SQL> desc samp;


Name Null? Type
---------------- ----------------- ----------------------------
ID NUMBER(5)
NAME VARCHAR2(10)

SQL> create table sample (id number(5) not null, name varchar2(10));

Table created.

SQL> desc sample;


Name Null? Type
---------------- ----------------- ----------------------------
ID NOT NULL NUMBER(5)
NAME VARCHAR2(10)

SQL> create table sample (id number(5), name varchar2(10), check(id in 2000));
Table created.

SQL> create table sample (id number(5), name varchar2(10), check(id not in 2000));
Table created.

SQL> create table sample (id number(5), name varchar2(10),


check(id between 2000 and 3000));
Table created.
Contents Max. Marks Marks Obtained
Design 20
Development 20
Queries & Execution 20
Viva Voce 20
Record 20
Total 100

Result:
Ex No. : 3

Aim:
To a write a PL/SQL program to implement cursors.

For Creating Database:

Algorithm:

1. Create a database with SQL for "bank" table with attributes "ac_no", "name" and
"balance”.
2. Set "ac_no" as primary key for that table.

Queries:

For creating database for “bank”

SQL> create table bank (ac_no number(11), name varchar2(10), balance number(5),
primary key(ac_no));

SQL> insert into bank values(&ac_no,'&name',&balance);

CURSORS

Algorithm:

For Deposit:

1. Start the procedure named withdraw


2. Declare 2 variables to get 2 integers
3. Declare a cursor named cur
4. get the balance into the cursor for the given account no
5. open the cursor and fetch the data into the variables
6. to update the current balance subtract the given amount to the existing balance
7. exit loop when cursor fetches null value
8. close cursor and end the procedure
For withdraw:
1. Start the procedure
2. Declare two variables as number for ac_no and amount.
3. Declare a cursor named cur
4. get the balance into the cursor for the given account no
5. open the cursor and fetch the data into the variables
6. to update the current balance add the given amount to the existing balance
7. close cursor and end the procedure

Queries:

For deposit:

SQL> create or replace procedure deposit(m number,n number) as


c number;
cursor cur is select balance from scott.bank where ac_no=m;
begin
open cur;
loop
fetch cur into c;
update bank set balance=c+n where bank.ac_no=m;
exit when cur%NOTFOUND;
end loop;
close cur;
end;
/

For Withdraw:

SQL> create or replace procedure withdraw(m number,n number) as


c number;
cursor cur is select balance from scott.bank where ac_no=m;
begin
open cur;
loop
fetch cur into c;
update bank set balance=c-n where bank.ac_no=m;
exit when cur%NOTFOUND;
end loop;
close cur;
end;
/
Database for the table “bank”:

SQL> desc bank

Name Null? Type


----------------------------------- ----------------- ----------------------------
AC_NO NOT NULL NUMBER(11)
NAME VARCHAR2(10)
BALANCE NUMBER(5)

Output:

For deposit:

SQL> select * from bank;

AC_NO NAME BALANCE


------------- ------------------------- -----------------
6152004 SaravanaKumar.S 2600
6152005 SathyaAnand.R 7200
6152006 Saravanan.A 2500

SQL> exec deposit(6152004,500)

PL/SQL procedure successfully completed.

SQL> select * from bank;

AC_NO NAME BALANCE


-------------- ------------------------ -----------------
6152004 SaravanaKumar.S 3100
6152005 SathyaAnand.R 7200
6152006 Saravanan.A 2500
For Withdraw:

SQL> select * from bank;

AC_NO NAME BALANCE


-------------- ------------------------ -----------------
6152004 SaravanaKumar.S 3100
6152005 SathyaAnand.R 7200
6152006 Saravanan.A 2500

SQL> exec withdraw(6152004,500);

PL/SQL procedure successfully completed.

SQL> select * from bank;

AC_NO NAME BALANCE


-------------- ------------------------ -----------------
6152004 SaravanaKumar.S 2600
6152005 SathyaAnand.R 7200
6152006 Saravanan.A 2500

SQL>
Contents Max. Marks Marks Obtained
Design 20
Development 20
Queries & Execution 20
Viva Voce 20
Record 20
Total 100

Result:
Ex No. : 4

Aim:
To a write a PL/SQL program to implement triggers.

For Creating Database:

Algorithm:
3. Create a database with SQL for "bank" table with attributes "ac_no", "name" and
"balance”.
4. Set "ac_no" as primary key for that table.

Queries:

For creating database for “bank”

SQL> create table bank (ac_no number(11), name varchar2(10), balance number(5),
primary key(ac_no));

SQL> insert into bank values(&ac_no,'&name',&balance);

TRIGGERS
For Negative Balance:

Algorithm:
1. Create a trigger
2. Declare a trigger trig that fires before insert or update of balance from table
“bank”.
3. Use row level trigger using for each row
4. While inserting or updating if balance is in negative, report an error
5. End trigger

Queries:
SQL> create or replace trigger mytrig
before insert or update of balance on
scott.bank
for each row
begin
if :new.balance<0 then
raise_application_error(-20003,'Negative balance not allowed');
end if;
end;
/
For Low balance:

Algorithm:

1. Create a trigger
2. Declare a trigger trig that fires before insert or update of balance from table
“bank”.
3. Use row level trigger using for each row
4. While inserting or updating if balance is less than 450, report an error
5. End trigger

Queries:

SQL> create or replace trigger trig


before insert or update of balance on
scott.bank
for each row
begin
if :new.balance<450 then
raise_application_error(-20003,’Balance low');
end if;
end;
/

Database for the table “bank”:

SQL> desc bank

Name Null? Type


----------------------------------- ----------------- ----------------------------
AC_NO NOT NULL NUMBER(11)
NAME VARCHAR2(10)
BALANCE NUMBER(5)

Output:

SQL> update bank set balance=200 where ac_no=6152004;


update bank set balance=200 where ac_no=6152004
*
ERROR at line 1:
ORA-20003: Balance low
ORA-06512: at "SCOTT.TRIG", line 3
ORA-04088: error during execution of trigger 'SCOTT.TRIG'
SQL> update bank set balance=-200 where ac_no=6152004;
update bank set balance=-200 where ac_no=6152004
*
ERROR at line 1:
ORA-20003: Negative balance not allowed
ORA-06512: at "SCOTT.MYTRIG", line 3
ORA-04088: error during execution of trigger 'SCOTT.MYTRIG'

SQL> update bank set balance=2600 where ac_no=6152004;

1 row updated.

SQL>
Contents Max. Marks Marks Obtained
Design 20
Development 20
Queries & Execution 20
Viva Voce 20
Record 20
Total 100

Result:
Ex No. : 5

Aim:
To a write a PL/SQL program to find factorial of a number and first ‘n’ numbers
of Fibonacci series using functions.

i) FACTORIAL

Algorithm:

1. Create a function named as fact.


2. Declare the variable N, T.
3. Get the value of N.
4. If n=1 then return 1.
5. If n>1 then return n*fact(n-1).
6. Execute the value of factorial using dbms_output.put_line().
7. End of program.

Queries:

SQL> create or replace function fact(n in number)


return number is
begin
If n=1 then
return 1;
Else
Return n*fact(n-1);
End if;
end;
/
SQL> declare
N number;
T number;
begin
N:=&NO;
T:=fact(N);
Dbms_output.put_line(‘THE FACTORIAL IS ‘||T);
end;
/
ii) FIBONACII SERIES

Algorithm:
1. Create a function fib.
2. Declare the variables I and N.
3. If n=1 then return 0.
4. If n=2 then return 1.
5. If n>2 then return fib(n-1)+fib(n-2).
6. Execute the series using dbms_output.put_line().
7. End of program.

Queries:

SQL> create or replace function fib(n in number)


return number is
begin
If n=1 then
return 0;
End if;
If n=2 then
return 1;
Else
Return fib(n-1)+fib(n-2);
End if;
end;
/
SQL> declare
i number;
n number;
f number;
begin
N:=&NO;
Dbms_output.put_line(‘FIBONACCI SERIES IS’);
For I in 1..N
Loop
F:=fib(I);
Dbms_output.put_line (F);
End loop;
end;
/
Output:

i) FACTORIAL

Enter value for no: 5


old 5: N:=&NO;
new 5: N:=5;
THE FACTORIAL IS 120

ii) FIBONACII SERIES

Enter value for no: 5


old 6: N:=&NO;
new 6: N:=5;
FIBONACCI SERIES IS
0
1
1
2
3
Contents Max. Marks Marks Obtained
Design 20
Development 20
Queries & Execution 20
Viva Voce 20
Record 20
Total 100

Result:
Ex No. : 6

Aim:
To a write a PL/SQL program to perform arithmetic operations and to find square
of a number using procedures.

i) ARITHMETIC OPERATIONS:

Algorithm:

1. Create the procedure arith using SQL.


2. Declare two variables for performing arithmetic operations.
3. Declare the variables for storing the result.
4. Perform the operations addition, subtraction, multiplication and division using the
variables.
5. Print the result.

Queries:

SQL> create or replace procedure arith(n1 in number, n2 in number) as


add1 number(5);
sub1 number(5);
mul1 number(5);
div1 number(5);
begin
add1:=n1+n2;
sub1:=n1-n2;
mul1:=n1*n2;
div1:=n1/n2;
dbms_output.put_line ('Addition value '||add1);
dbms_output.put_line ('Subtraction value '||sub1);
dbms_output.put_line ('Multiplication value '||mul1);
dbms_output.put_line ('Division value '||div1);
end;
/
SQL> declare
a number(5):=&a;
b number(5):=&b;
begin
arith (a,b);
end;
/
ii) SQUARE Of GIVEN NUMBER:

Algorithm:
1. Create the procedure in SQL to find the square of given numbers.
2. Declare the variables for performing the operations.
3. Declare the variables to store the result.
4. Perform the operation of squaring the given numbers using the variables.
5. Print the result.
6. Display the result using dbms commands.

Queries:

SQL> create or replace procedure sq(a1 in number) as


b1 number;
res number;
begin
res:=a1*a1;
b1:=res;
dbms_output.put_line('Square of a:'||b1);
end;
/

SQL> declare
a number(5):=&a;
begin
sq(a);
end;
/
Output:

i) ARITHMETIC OPERATIONS:

Enter value for a: 20


old 2: a number(5):=&a;
new 2: a number(5):=20;
Enter value for b: 4
old 3: b number(5):=&b;
new 3: b number(5):=4;
Addition value 24
Subtraction value 16
Multiplication value 80
Division value 5

ii) SQUARE Of GIVEN NUMBER:

Enter value for a: 5


old 2: a number(5):=&a;
new 2: a number(5):=5;
Square of a:25
Contents Max. Marks Marks Obtained
Design 20
Development 20
Queries & Execution 20
Viva Voce 20
Record 20
Total 100

Result:
Ex No. : 7

Aim:
To write a java program to embedded SQL statement and execute the SQL
queries.

For Creating Database:

Algorithm:

5. Create a database with SQL for "bank" table with attributes "ac_no", "name" and
"balance”.
6. Set "ac_no" as primary key for that table.

Queries:

For creating database for “bank”

SQL> create table bank (ac_no number(11), name varchar2(10), balance number(5),
primary key(ac_no));

SQL> insert into bank values(&ac_no,'&name',&balance);

For Java Programing:

For INSERT:

Algorithm:
1. Establish the connection between jdbc and odbc using
DriverManager.GetConnection ().
2. Now insert the values into the table.
3. Display the results.
Program:

import java.io.*;
import java.sql.*;

class Ins
{
public static void main(String a[]) throws IOException
{
DataInputStream in=new DataInputStream(System.in);
String str1,str2,str3,str4;
System.out.println("Enter the Ac_no:");
str1=in.readLine();
System.out.println("Enter the Name:");
str2=in.readLine();
System.out.println("Enter the Balance:");
str3=in.readLine();
System.out.println("Enter the Ac_Type:");
str4=in.readLine();
ResultSet result;
String str=new String();
str="insert into bank values ("+str1+",'"+str2+"',"+str3+",'"+str4+"')";
try
{
/*Method1 using jdbc-odbc*/
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//Connection con = DriverManager.getConnection("jdbc:odbc:MyProj","scott","tiger");

/*Method2 using jdbc-oci*/


DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
Connection con=DriverManager.getConnection("jdbc:oracle:oci8:scott/tiger@db9");

Statement stat=con.createStatement();
stat.executeUpdate(str);
System.out.println("\n1 row inserted.");
}
catch(Exception e)
{
System.out.println("\nError:"+e);
}
}
}
For SELECT:

Algorithm:
1. Insert the values into the table using SQL.
2. Establish the connection between jdbc and odbc using
DriverManager.GetConnection ().
3. Select the row(s) to be displayed.
4. Display the results.

Program:

import java.io.*;
import java.sql.*;

class Sel
{
public static void main(String a[])throws IOException
{
ResultSet result;
String str1=new String();
str1="Select * from bank ";
try
{
/*Method1 using jdbc-odbc*/
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//Connection con=DriverManager.getConnection("jdbc:odbc:MyProj","scott","tiger");

/*Method2 using jdbc-oci*/


DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
Connection con=DriverManager.getConnection("jdbc:oracle: oci8:scott/tiger@db9");

Statement stat=con.createStatement();
result=stat.executeQuery(str1);
System.out.println("\nAc_No\tName\t\t\tBalance\tAc_Type\n");
System.out.println("-----------------------------------------------\n");
while(result.next())
{
System.out.println( result.getString(1) + "\t" + result.getString(2) + "\t\t" +
result.getString(3) + "\t" + result.getString(4));
}
}
catch(Exception e)
{
System.out.println("\nError:"+e);
}
}
}
For DELETE:
Algorithm:
1. Insert the values into the table using SQL.
2. Get the acc_no that is to be deleted.
3. Establish the connection between jdbc and odbc using
DriverManager.GetConnection ().
4. Delete the row from the table.
5. Display the results.

Program:

import java.io.*;
import java.sql.*;

class Del
{
public static void main(String a[]) throws IOException
{
DataInputStream in=new DataInputStream(System.in);
String str;
System.out.println("Enter the Ac_no:");
str=in.readLine();
ResultSet result;
String str1=new String();
str1="delete from bank where ac_no="+str;
try
{
/*Method1 using jdbc-odbc*/
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//Connection con=DriverManager.getConnection("jdbc:odbc:MyProj","scott","tiger");

/*Method2 using jdbc-oci*/


DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
Connection con=DriverManager.getConnection("jdbc:oracle: oci8:scott/tiger@db9");

Statement stat=con.createStatement();
stat.executeUpdate(str1);
System.out.println("\n1 row Deleted.");
}
catch(Exception e)
{
System.out.println("\nError:"+e);
}
}
}

For UPDATE:
Algorithm:
1. Insert the values into the table using SQL.
2. To Update, enter the acc_no and the new amount.
3. Validate the connection between jdbc and odbc using
DriverManager.GetConnection ().
4. Update the table using executeUpdate command in the embedded SQL.
5. Display the results.

Program:

import java.io.*;
import java.sql.*;
import java.lang.*;

class Upd
{
public static void main(String a[])throws IOException
{
DataInputStream in=new DataInputStream(System.in);
String str4,str3;
Double d1,d2;
System.out.println("Enter the Ac_no:");
str4=in.readLine();
System.out.println("Enter the Deposit_Amount:");
str3=in.readLine();
d1=Double.parseDouble(str3);
ResultSet result;
String str1=new String();
String st;
String str2=new String();
str2="select * from bank where ac_no="+str4;
try
{
/*Method1 using jdbc-odbc*/
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//Connection con=DriverManager.getConnection("jdbc:odbc:MyProj","scott","tiger");

/*Method2 using jdbc-oci*/


DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
Connection con=DriverManager.getConnection("jdbc:oracle: oci8:scott/tiger@db9");
Statement stat=con.createStatement();
result=stat.executeQuery(str2);
result.next();
d2=Double.parseDouble(result.getString(3));
d1=d1+d2;
st=Double.toString(d1);
str1="update bank set balance="+st+"where ac_no="+str4;
stat.executeUpdate(str1);
System.out.println("\n1 row Updated.");
}
catch(Exception e)
{
System.out.println("\nError:"+e);
}
}
}

Database for the table “bank”:

SQL> desc bank

Name Null? Type


----------------------------------- ----------------- ----------------------------
AC_NO NOT NULL NUMBER(11)
NAME VARCHAR2(10)
BALANCE NUMBER(5)

Output:
For SELECT:

For Update:

For INSERT:
For DELETE:
Contents Max. Marks Marks Obtained
Design 20
Development 20
Queries & Execution 20
Viva Voce 20
Record 20
Total 100

Result:

Ex No. : 8
Aim:
To design and implementing Entity-Relationship model using Oracle and
Visual Basic

For Creating Backend :

Algorithm:
1. Create a database using SQL for "student" table with attributes name, regno,
DOB, address1, address2, state, zipcode.
2. Set the regno of "Student" table as primary key.
3. Create another database using SQL for table "test" with attributes regno,
DBMS, CN, POM, MP_MC, DM, TOC.
4. Set regno of “Test” table as primary key.

Queries:

For creating the database “student”:


SQL> create table student (regno number(10), name varchar2(10), dob date,
addr1 varchar2(10), addr2 varchar2(10), state varchar2(10),
zipcode number(10), primary key (regno));
SQL> insert into student values (&regno, '&name', &dob, '&addr1', '&addr', '&state',
&zipcode);

For creating the database “test”:


SQL> create table test (regno number(10), DBMS number(3), CN number(3),
POM number(3), MP_MC number(3), DM number(3),
TOC number(3), primary key (regno));
SQL> insert into test values(&regno,'&name',&dob,'&addr1','&addr','&state',&zipcode);

For Creating Frontend:

Algorithm:
1. Create a form with form name “frm_Personal” for displaying the personal
details.
2. Create a form with form name “frm_Mark” for displaying the Marks.
3. Create a form with form name “frm_Student” with 3 command button for
"Student", "Mark" and “close” add the corresponding codes for the button.
4. On clicking the Student button, the personal details of all the student in the
database are displayed.
5. On clicking the Test button, the marks of the students whose register number
matches with those in Student table alone are displayed.
Coding:
Form name = frm_Student

 Coding for Student command :

Private Sub cmdPersonal_Click()


frm_Personal.Show
End Sub

 Coding for Test command :

Private Sub cmdMark_Click()


frm_Mark.Show
End Sub

 Coding for Close command :

Private Sub cmdClose_Click()


Unload me
End Sub

Form name = frm_Personal

 Coding for Close command :

Private Sub cmdClose_Click()


Unload me
End Sub

Form name = frm_Mark

 Coding for Close command :

Private Sub cmdClose_Click()


Unload me
End Sub
Database for the table “student’:

SQL> desc student

Name Null? Type


----------------------------------- ----------------- ----------------------------
REGNO NOT NULL NUMBER(10)
NAME VARCHAR2(10)
DOB DATE
ADDR1 VARCHAR2(10)
ADDR2 VARCHAR2(10)
STATE VARCHAR2(10)
ZIPCODE NUMBER(10)

Database for the table “test”:

SQL> desc test

Name Null? Type


----------------------------------- ----------------- ----------------------------
REGNO NOT NULL NUMBER(10)
DBMS NUMBER(3)
CN NUMBER(3)
POM NUMBER(3)
MP_MC NUMBER(3)
DM NUMBER(3)
TOC NUMBER(3)
Output:
Contents Max. Marks Marks Obtained
Design 20
Development 20
Queries & Execution 20
Viva Voce 20
Record 20
Total 100

Result:

Ex No. : 9
Aim:
To design a payroll processing and implementing the process using Oracle and
Visual Basic

For Creating Backend:

Algorithm:

1. Create a database using SQL for “payroll” table with attributes emp_id,
emp_name, DOB, experience, gender, age, address, DOJ, basic salary, HRA, PF
and TA.
2. Set primary key for emp_id

Queries:

For creating the database “payroll”:

SQL> create table payroll( id number(5), name varchar2(10), dob date,


exp number(4), gender varchar2(10), age number(3),
addr varchar2(10), doj date, bpay number(10),
hra number(5,2), ta number(5,2), pf number(5,2));

SQL> insert into payroll values(&id, '&name', &dob, &exp, '&gender', &age, '&addr',
&doj, &bpay, &hra, &ta, &pf);

For Creating Frontend:

Algorithm:

1. Place a form with from name "frm_Main" and Place 6 command buttons for
“add”, "update", "delete", "allowance", "report" and "exit" and enter
corresponding coding.
2. "add" is used to add new empolyee details.
3. "update" is used to make changes in existing details of an employee.
4. "delete" is used to remove details of particular employee.
5. "allowance" will perform calculation for allowance of an employee.
6. "report" will display employee name,emp_id ,gross salary and net salary.
7. Place form with form name "frm_Report" and place 3 command buttons for
"back", "print" and "exit".
8. "Back" will take us to "frm_Main".
Coding:

Form name = frm_Main

 Coding for Add command :

Private Sub cmdAdd_Click()


Adodc1.Recordset.AddNew
End Sub

 Coding for update command :

Private Sub cmdUpdate_Click()


Adodc1.Recordset.Update
MsgBox "Record Updated"
End Sub

 Coding for Delete command :

Private Sub cmdDelete_Click()


Adodc1.Recordset.Delete
MsgBox "Record Deleted"
End Sub

 Coding for Allowance command :

Private Sub cmdAllow_Click()


txt_HRA.Text = txt_Basic.Text / 100 * 12
txt_PF.Text = txt_Basic.Text / 100 * 8
txt_TA.Text = txt_Basic.Text / 100 * 4
End Sub

 Coding for Report command :

Private Sub cmdReport_Click()


frm_Report.Show
frm_Report.txt_EmpName.Text = txt_EmpName.Text
frm_Report.txt_EmpID.Text = txt_EmpID.Text
frm_Report. txt_NetSal.Text = txt_Basic.Text
frm_Report.txt_GrossSal.Text = Val(txt_Basic.Text) +
Val(txt_HRA.Text) – Val(txt_PF.Text) +Val(txt_TA.Text)
End Sub

 Coding for Exit command :


Private Sub cmdExit_Click()
Unload me
End Sub

Form name = frm_Report

 Coding for Back command :

Private Sub cmdBack_Click()


Frm_Main.Show
End Sub

 Coding for Print command :

Private Sub cmdPrint_Click()


Frm_Main.printform
End Sub

 Coding for Exit command :

Private Sub cmdExit_Click()


Unload me
End Sub

Database for the table “payroll”:

SQL> desc payroll

Name Null? Type


----------------------------------- ----------------- ----------------------------
ID NUMBER(5)
NAME VARCHAR2(10)
DOB DATE
EXP NUMBER(4)
GENDER VARCHAR2(10)
AGE NUMBER(3)
ADDR VARCHAR2(10)
DOJ DATE
BPAY NUMBER(10)
HRA NUMBER(5,2)
TA NUMBER(5,2)
PF NUMBER(5,2)
Output:
Contents Max. Marks Marks Obtained
Design 20
Development 20
Queries & Execution 20
Viva Voce 20
Record 20
Total 100

Result:
Ex No. : 10

Aim:
To design a banking system and implementing the process using Oracle and
Visual Basic

For Creating Backend :

Algorithm:

1. Create a database using SQL for "bank" table with attributes "ac_no", "name" and
"balance”
2. Set "ac_no" as primary key for that table.

Queries:

For creating the database “bank’:

SQL> create table bank( ac_no number(11), name varchar2(10), balance number(5),
primary key(ac_no));

SQL> insert into bank values(&ac_no, '&name', &balance);

For Creating Frontend:

Algorithm:

1. Place a form with form name "frm_Main" and caption and 4 command buttons
for "deposit", "withdraw", "Balance Enquiry" and “Exit” and enter corresponding
codings.
2. "Deposit " will add money to the account if we give account number and amount
to be added. If given account number is wrong, then the message "NOT FOUND"
will be displayed.
3. "withdraw" will drop money from the account .
4. "Balance Enquiry" will display the current balance in given account number.
5. Place a form with form name "process" and place 2 buttons for “process” and
“cancel" and enter corresponding coding.

Coding:

Form name = frm_Main

 Coding for Deposit command :

Private Sub cmdDeposit_Click()


frm_process.Show
frm_Main.Caption = "Deposit System"
frm_process.cmdProcss.Caption = “Deposit”
End Sub

 Coding for Withdraw command :

Private Sub cmdWithdraw_Click()


frm_process.Show
frm_Main.Caption = "Withdraw System"
frm_process.cmdProcss.Caption = “Withdraw”
End Sub

 Coding for Balance Enquiry command :

Private Sub cmdBalance_Click()


frm_process.Show
frm_Main.Caption = "Balance Enquiry System"
frm_process.lblAmt.Visible = False
frm_process.lblAmt.Visible = False
frm_process.cmdProces.Caption = "Check"
End Sub

 Coding for Close command :

Private Sub cmdClose_Click()


Unload me
End Sub

 Coding for Form Active (when ever the form gets active) :

Private Sub frm_Main_Activate()


frm_Main.Caption = "Bank Processing System"
End Sub

Form name = frm_Process

 Coding for Process command :

Private Sub cmdProcess_Click()


Dim str, str1, str2 As String
str = "ac_no="
str1 = txt_AcNo.Text
str2 = str + str1
If cmdProcess.Caption = "Check" Then
Adodc1.Recordset.Filter = str2
lblBalance.Visible = True
End If
If cmdProcess.Caption = "Withdraw" Then
Adodc1.Recordset.Filter = str2
lblBalance.Visible = False
If lblBalance.Caption = "" Then
MsgBox ("not found")
Else
val1 = lblBalance.Caption
val2 = Text2.Text
val3 = val1 - val2
lblBalance.Caption = val3
Adodc1.Recordset.Update
Adodc1.Recordset.Save
lblBalacne.Visible = True
End If
End If
If cmdProcess.Caption = "Deposit" Then
Adodc1.Recordset.Filter = str2
lblBalance.Visible = False
If lblBalance.Caption = "" Then
MsgBox ("not found")
Else
val1 = lblBalance.Caption
val2 = txtAmt.Text
val3 = Val(val1) + Val(val2)
lblBalance.Caption = val3
Adodc1.Recordset.Update
Adodc1.Recordset.Save
lblBalance.Visible = True
End If
End If
End Sub

 Coding for Cancel command :

Private Sub cmdCancel_Click()


Unload Me
End Sub

 Coding for Form Load (when ever form gets loaded) :

Private Sub frm_Process_Load()


lblBalance.Visible = False
End Sub

Design of the table “bank”:

SQL> desc bank

Name Null? Type


----------------------------------- ----------------- ----------------------------
AC_NO NOT NULL NUMBER(11)
NAME VARCHAR2(10)
BALANCE NUMBER(5)
Output:
Contents Max. Marks Marks Obtained
Design 20
Development 20
Queries & Execution 20
Viva Voce 20
Record 20
Total 100

Result:
Ex No. : 11

Aim:
To design a Library information system and implementing the process using
Oracle and Visual Basic

For Creating Backend :

Algorithm:
1. Create a database using SQL for “lib” table with attributes book_name, id, author,
publisher, ISBN, level, price and edition.
2. Create another database using SQL for “member” table with member_id,
max_books and validity.
3. Set primary key for member_id.

Queries:

For creating the database “library”:


SQL> create table lib (id number(6), book_name varchar2(10), author varchar2(10),
ISBN varchar2(10), publisher varchar2(10),
Book_level varchar2(10), price number(4),
edition varchar2(10));
SQL> insert into library values (&id, '&name', '&author', '&ISBN', '&publisher', '&level',
'&price', '&edition');

For creating the database “member”:


SQL> create table member (id number(10), max_books number(2), validity date,
primary key(id));
SQL> insert into member values(&id, &max_books, &validity);

For Creating Frontend:

Algorithm:
1. Place a form with form name "frm_Main" and 3 commands buttons for "book
details", "student details" and "close" and enter corresponding codings.
2. If we click "student details", there appears a form (frm_Search), enter member_id
in it. If give member_id is correct then a form(frm_Member) will display the
student name, maximum number of books and validity.
3. If we click "BookDetails", there appears a form (frm_Book) with menu
consisting "search", "update" and "delete".
4. Using "search" menu, if we give book_name, then author, publisher, ISBN, id,
level, price and edition will be displayed.
5. Using "Update" menu, we can make changes and save the record.
6. Using "delete" menu, we can delete the unwanted book details.

Coding:

Form name = frm_Main

 Coding for Book Details command :

Private Sub cmdBook_Click()


frm_Book.Show
End Sub

 Coding for Member Details command :

Private Sub cmdMember_Click()


frmSearch.Show
frmSearch.lblFind.Caption = "Member ID"
End Sub

 Coding for Close command :

Private Sub cmdClose_Click()


Unload me
End Sub

Form name = frm_Book

 Coding for Delete menu :

Private Sub mnu_opt_del_Click()


If Adodc1.Recordset.EOF = False Then
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveNext
Else
MsgBox ("Error: Deleting record that does not exist.")
End If
End Sub
 Coding for Exit menu :

Private Sub mnu_file_exit_Click()


Unload Me
End Sub

 Coding for Search menu :

Private Sub mnu_opt_search_Click()


frm_Search.Show
End Sub

 Coding for Update menu :

Private Sub mnu_opt_update_Click()


Adodc1.Recordset.Update
End Sub

Form name = frm_Member

 Coding for Ok Command :

Private Sub cmdOk_Click()


Adodc1.Recordset.Update
Unload Me
End Sub

Form name = frm_Search

 Coding for Cancel Command :

Private Sub cmdCancel_Click()


Unload Me
End Sub

 Coding for Ok Command :

Private Sub cmdOk_Click()


Dim a, b, c As String
If lblFind.Caption = "Book Name" Then
b = "book_name="
c = txtFind.Text
a = b + "'" + c + "'"
frm_Book.Adodc1.Recordset.Filter = a
If frm_Book.txtFind.Text <> "" Then
MsgBox ("Book Found")
Else
MsgBox ("Book Not Found")
End If
Frm_Book.Adodc1.Refresh
Unload Me
End If
If lblFind.Caption = "Member ID" Then
b = "Reg_no="
c = txtFind.Text
a = b + "'" + c + "'"
frm_Member.Adodc1.Recordset.Filter = a
frm_Member.Show
Unload Me
End If
End Sub

Database for the table “lib”:

SQL> desc lib

Name Null? Type


----------------------------------- ----------------- ----------------------------
ID NUMBER(6)
BOOK_NAME VARCHAR2(10)
AUTHOR VARCHAR2(10)
ISBN VARCHAR2(10)
PUBLISHER VARCHAR2(10)
BOOK_LEVEL VARCHAR2(10)
PRICE NUMBER(4)
EDITION VARCHAR2(10)

Database for the table “member”:


SQL> desc member

Name Null? Type


----------------------------------- ----------------- ----------------------------
ID NOT NULL NUMBER(10)
MAX_BOOKS NUMBER(2)
VALIDITY DATE
Output:
Contents Max. Marks Marks Obtained
Design 20
Development 20
Queries & Execution 20
Viva Voce 20
Record 20
Total 100

Result:

You might also like