You are on page 1of 79

EX NO : 1 AIM:

Data Definition Language

To study and execute the data definition language queries.

INTRODUCTION: A Data Definition Language (DDL) is a computer language for defining data structures. The term was first introduced in relation to the Codasyl database model, where the schema of the database was written in a Data Definition Language describing the records, fields, and "sets" making up the user Data Model. Initially it referred to a subset of SQL, but is now used in a generic sense to refer to any formal language for describing data or information structures, like XML schemas. SQL: Initially, DDL was a subset of SQL statements. CREATE statements: Create - To make a new database, table, index, or stored query. A CREATE statement in SQL creates and object inside of a relational database management system (RDBMS). The types of objects that can be created depend on which RDBMS is being used, but most support the creation of tables, indexes, users, and databases. Some systems (such as PostgreSQL) allow CREATE, and other DDL commands, inside of a transaction and thus they may be rolled back. CREATE TABLE: Perhaps the most common CREATE command is the CREATE TABLE command. The typical usage is: CREATE TABLE [table name] ( [column definitions] ). DROP statements: Drop - To destroy an existing database, table, index, or view.A DROP statement in SQL removes an object from a RDBMS. The types of objects that can be dropped depends on which RDBMS is being used, but most support the dropping of tables, users, and databases.. The typical usage is simply DROP objecttype objectname. For example, the command to drop a table named employees would be: DROP TABLE employees;

ALTER statements: Alter - To modify an existing database object. An ALTER statement in SQL changes the properties of an object inside of a relational database management system (RDBMS). The types of objects that can be altered depends on which RDBMS is being used. The typical usage is ALTER objecttype objectname parameters. For example, the command to add (then remove) a column named bubbles for an existing table named sink would be: ALTER TABLE sink ADD bubbles INTEGER; ALTER TABLE sink DROP COLUMN bubbles; Data Manipulation Language (DML) : DML is a family of computer languages used by computer programs and/or database users to retrieve, insert, delete and update data in a database. Currently the most popular data manipulation language is that of SQL, which is used to retrieve and manipulate data in a Relational database. Other forms of DML are those used by IMS/DLI, CODASYL databases (such as IDMS), and others. Data Manipulation Languages have their functional capability organized by the initial word in a statement, which is almost always a verb. In the case of SQL, these verbs are: 1.Select 2.Insert 3.Update 4.Delete Each SQL statement is a declarative command. The individual SQL statements are declarative, as opposed to imperative, in that they describe what the program should accomplish, rather than describing how to go about accomplishing it. Most SQL implementations extend their SQL capabilities by providing imperative, i.e., procedural languages.Examples of these are Oracle's PL/SQL and DB2's SQL PL. There are two types of Data Manipulation languages: Procedural Declarative Data Control Language:

A Data Control Language (DCL) is a computer language and a subset of SQL, used to control access to data in a database. Examples of DCL commands include: GRANT to allow specified users to perform specified tasks. REVOKE to cancel previously granted or denied permissions. A LIBRARY DATABASE CONTAINS THE FOLLOWING: 1. BOOKDELIVERED : b_bookid, b_bookname, b_studid, b_dateofreturn 2. BOOKPURCHASED : b_bookid, b_bookname, b_author, b_bookprice, b_quantity, b_studid, b_dateofpurchase, b_edition, 3. COLLEGE 4. DEPARTMENT 5. FINEAMOUNT 6. STUDENT QUERIES: 1. Create all the tables namely college, department, student, book_delivered, book_purchased, fine_amount. 2. Create primary keys for all the tables that have been created. 3. Generate the reference keys from the parent table. 4. Add a column in student named as mailid. 5. Change the size of the field name. 6. Make as a default value for the regulation for 2008 batch. 7. Create a new column Edition in Bookdelivered and then drop it. 8. Display all the constraint names and column name present in it. PROCEDURE: Create all the tables namely college, department, student, book delivered, book purchased, fine amount. SQL>create table bookdelivered(b_bookid number(5),b_bookname varchar2(5),b_studid number(6),b_dateofreturn date); Table created. : c_name, c_code. : d_no, d_name, c_code. : b_bookid, b_latedate, b_dateofreturn, b_studid : s_studid, s_name, s_dob, s_doj, s_regulation, s_gender, s_deptno.

SQL> desc bookdelivered; Name B_BOOKID B_BOOKNAME B_STUDID B_DATEOFRETURN Null? Type NUMBER(5) VARCHAR2(5) NUMBER(6) DATE ------------------------------- -------- ----

SQL>create table bookpurchased(b_bookid number(5),b_bookname varchar2(5),b_author varchar2(10),b_bookprice number(4),b_quantity number(2),b_studid number(6),b_dateofpurchased date,b_edition number(2)); Table created. SQL> desc bookpurchased; Name B_BOOKID B_BOOKNAME B_AUTHOR B_BOOKPRICE B_QUANTITY B_STUDID B_DATEOFPURCHASED B_EDITION Null? Type NUMBER(5) VARCHAR2(5) VARCHAR2(10) NUMBER(4) NUMBER(2) NUMBER(6) DATE NUMBER(2)

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

SQL> create table college(c_name varchar2(15),c_code number(4)); Table created. SQL> desc college; Name C_NAME Null? Type VARCHAR2(15) ------------------------------- -------- ----

C_CODE

NUMBER(4)

SQL> create table department(d_no number(5),d_name varchar2(10),c_code number(4)); Table created. SQL> desc department; Name D_NO D_NAME C_CODE Null? Type NUMBER(5) VARCHAR2(10) NUMBER(4) ------------------------------- -------- ----

SQL> create table fineamount(b_bookid number(5),b_dateofreturn date,b_latedate date,b_studid number(6)); Table created. SQL> desc fineamount; Name B_BOOKID B_DATEOFRETURN B_LATEDATE B_STUDID Null? Type NUMBER(5) DATE DATE NUMBER(6) ------------------------------- -------- ----

SQL> create table student (s_studid number(6),s_name varchar2(8),s_dob date,s_doj date,s_regulation number(5),s_gender varchar2(2),s_deptno number(5)); Table created.

SQL> desc student;

Name S_STUDID S_NAME S_DOB S_DOJ S_REGULATION S_GENDER S_DEPTNO

Null? Type NUMBER(6) VARCHAR2(8) DATE DATE NUMBER(5) VARCHAR2(2) NUMBER(5)

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

2.Create primary key for all the tables that have been created. SQL> alter table bookdelivered add(constraints A primary key (b_bookid)); Table altered. SQL> desc bookdelivered; Name B_BOOKID B_BOOKNAME B_STUDID B_DATEOFRETURN Null? Type ------------------------------- -------- --------------------NOT NULL NUMBER(5) VARCHAR2(5) NUMBER(6) DATE

SQL> alter table bookpurchased add(constraints B primary key (b_bookid)); Table altered. SQL> desc bookpurchased; Name B_BOOKID B_BOOKNAME B_AUTHOR B_BOOKPRICE B_QUANTITY B_STUDID Null? Type ------------------------------- -------- --------- ---------------NOT NULL NUMBER(5) VARCHAR2(5) VARCHAR2(10) NUMBER(4) NUMBER(2) NUMBER(6)

B_DATEOFPURCHASED B_EDITION

DATE NUMBER(2)

SQL> alter table college add(constraints C primary key (c_code)); Table altered. SQL> desc college; Name C_NAME C_CODE NOT NULL Null? Type VARCHAR2(15) NUMBER(4) ------------------------------- -------- --------------

SQL> alter table department add(constraints D primary key (d_no)); Table altered. SQL> desc department; Name D_NO D_NAME C_CODE Null? Type ------------------------------- -------- ---------------NOT NULL NUMBER(5) VARCHAR2(10) NUMBER(4)

SQL> alter table fineamount add(constraints E primary key (b_bookid)); Table altered. SQL> desc fineamount; Name B_BOOKID B_DATEOFRETURN B_LATEDATE B_STUDID Null? Type ------------------------------- -------- -------------NOT NULL NUMBER(5) DATE DATE NUMBER(6)

SQL> alter table student add(constraints F primary key (s_studid));

Table altered. SQL> desc student; Name S_STUDID S_NAME S_DOB S_DOJ S_REGULATION S_GENDER S_DEPTNO Null? NOT NULL Type NUMBER(6) VARCHAR2(8) DATE DATE NUMBER(5) VARCHAR2(2) NUMBER(5) ------------------------------- -------- --------------------------

3.Generate the reference keys from the parent table. SQL> alter table bookdelivered add constraints stud_ref1 foreign key(b_studid)references student(s_studid); Table altered. SQL> alter table bookpurchased add constraints stud_ref2 foreign key(b_studid)references student(s_studid); Table altered. SQL> alter table department add constraints coll_ref foreign key (c_code)references college (c_code); Table altered. SQL> alter table student add constraints dept_ref foreign key (s_deptno)references department(d_no); Table altered. SQL> alter table fineamount add constraints stud_ref3 foreign key (b_studid)references student(s_studid); Table altered.

SQL> select table_name ,constraint_name,constraint_type from user_constraints; TABLE_NAME BOOKDELIVERED BOOKPURCHASED FINEAMOUNT STUDENT DEPARTMENT BOOKDELIVERED BOOKPURCHASED COLLEGE DEPARTMENT FINEAMOUNT STUDENT 11 rows selected. 4.Add a column in student named as mailed. SQL> alter table student add(s_mailid varchar2(20)); Table altered. SQL> desc student; Name S_STUDID S_NAME S_DOB S_DOJ S_REGULATION S_GENDER S_DEPTNO S_MAILID Null? NOT NULL Type NUMBER(6) VARCHAR2(8) DATE DATE NUMBER(5) VARCHAR2(2) NUMBER(5) VARCHAR2(20) ------------------------------- -------- ---CONSTRAINT_NAME STUD_REF1 STUD_REF2 STUD_REF3 DEPT_REF COLL_REF A B C D E F C R R R R R P P P P P P ------------------------------ ------------------------------ ---------- -------

5.Change the size of the field name. SQL> alter table student modify(s_name varchar2(9)); Table altered. SQL> desc student; Name S_STUDID S_NAME S_DOB S_DOJ S_REGULATION S_GENDER S_DEPTNO S_MAILID Null? NOT NULL Type NUMBER(6) VARCHAR2(9) DATE DATE NUMBER(5) VARCHAR2(2) NUMBER(5) VARCHAR2(20) ------------------------------- -------- ------------------

6.Make as a default value for the regulation for 2008 batch. SQL> alter table student modify(s_regulation default'2008'); Table altered. 7.Create a new column 'Edition' in book delivered and drop it. SQL> alter table bookdelivered add (b_edition number(5)); Table altered. SQL> desc bookdelivered; Name B_BOOKID B_BOOKNAME B_STUDID B_DATEOFRETURN B_EDITION Null? Type NOT NULL NUMBER(5) VARCHAR2(5) NUMBER(6) DATE NUMBER(5) ------------------------------- -------- ----

SQL> alter table bookdelivered drop column b_edition; Table altered. SQL> desc bookdelivered; Name B_BOOKID B_BOOKNAME B_STUDID B_DATEOFRETURN Null? Type NOT NULL NUMBER(5) VARCHAR2(5) NUMBER(6) DATE ------------------------------- -------- ----

8.Display all the constraint names and column name present in it. SQL> select c.table_name,c.constraint_name,c.constraint_type,p.column_name from user_constraints c,user_cons_columns p where c.constraint_name=p.constraint_name; TABLE_NAME CONSTRAINT_NAME C COLUMN_NAME

-----------------------------------------------------------------------------------------------BOOKDELIVERED BOOKDELIVERED BOOKPURCHASED BOOKPURCHASED COLLEGE DEPARTMENT DEPARTMENT FINEAMOUNT STUD_REF1 A STUD_REF2 B C COLL_REF D STUD_REF3 R P R P P R P R B_STUDID B_BOOKID B_STUDID B_BOOKID C_CODE C_CODE D_NO B_STUDID

FINEAMOUNT STUDENT STUDENT 11 rows selected.

E DEPT_REF F

P R P

B_BOOKID S_DEPTNO S_STUDID

RESULT: Thus the DDL queries were executed and studied sucessfully.

EX NO: 2 AIM:

Data Manipulation Language

To study and execute the DML queries. INTRODUCTION: Data Manipulation Language: Data manipulation language allows the users to query and manipulate data in existing scheme in object.It allows following data to insert, delete, update and recovery data in schema object. Transaction Control Language: It manages the changes made by the dml commands. Commands are commit, savepoint, and roll back. Data Control Languages: It allows users to perform the operations using grant and revock commands. DML commands: Insert: Values can be inserted into table using insert commands. There are two types of insert commands. They are Multiple value insert command(using & symbol) Single value insert command(without using & symbol) Syntax: Insert into <tablename> values (&fieldname1(belongs to varchar2 type or date), &fieldname2(belongs to number type),& fieldnameN); Update: This allows the user to update the particular column value using the where clause condition. Syntax: Update <tablename> set <col1=value> where<col=value>; Delete: This allows you to delete the particular column values using where clause condition. Syntax: Delete from <tablename> where <condition>;

Select: This command is used to select the record from the table or view. Syntax: Select<col1.colN>/* from <tablename>; TCL commands: Commit: The commit statement explicitly makes permanently any changes that to be database during transaction. Commit also makes those changes visible to other user. So, the commit statement is current statement. Syntax: Commit; Savepoint: The savepoint makes names and masks the current point in the processing of transaction. Using savepoint with Rollback, weekend undo and a part of the transaction, instead of whole transaction. Maximum number of transaction is 5. Syntax: Savepoint savepoint_name; Rollback: Rollback statement thus exactly opposite to the commit. I t ends the current transaction and discuss any changes make during that transaction after the commit or savepoint. Syntax: Rollback; DCL Commands: Grant: By using the grant command you can grant any system. The privileges are role to another role. System privilege with admin option clause permits the grant to after the privileges on role on another user or roles. Grants can also revoke a role from the user as well. We can also specify all to grant all privileges. Syntax: Grant <system privilege> on <tablename> to <username>; Revoke: Privilege granted can be taken away by the revoke command. This command is almost similar to that of the grant command in its command. Syntax: Revoke <system privilege> on <tablename> from <username>;

Renaming a table: You can rename a table provided you are the owner of the table. Syntax: Rename <oldtablename> to <newtablename> Truncating the table: Truncating a table is removing all records from the table. The structure of the table stays intact. The SQL language has a Delete statement which can be used to remove one or more rows from a table. Truncation releases storage space occupies by the table, but deletion does not. Syntax: Truncate table <tablename>; QUERIES: 1. Insert the records in each created table. 2. List down the full details of the student database. 3. Modify the student id of college VV where department is CSE in student database. 4. Delete the record of the table book purchased where book has been purchased with different editions. 5. Display the student details in ascending order. 6. Group all the department of the table college. 7. Display all the student of IT and MECH with college information. 8. Get the student information of CIVIL and ECE department present in library database. 9. Display either the IT student or CSE student from VV. PROCEDURE: 1.Insert the records in each created table. SQL> insert into bookdelivered values(&b_bookid,'&b_bookname',&b_studid,'&b_date ofreturn'); Enter value for b_bookid: 001 Enter value for b_bookname: dbms Enter value for b_studid: 123 Enter value for b_dateofreturn: 4-jan-12 1 row created.

SQL> insert into BOOKPURCHASED values(&b_bookid, '&b_bookname','&b_author', &b_b ookprice,&b_quantity,&b_studid,'&b_dateofpurchase',&b_edition); Enter value for b_bookid: 444 Enter value for b_bookname:dbms Enter value for b_author: mano Enter value for b_bookprice: 220 Enter value for b_quantity: 2 Enter value for b_studid: 002 Enter value for b_dateofpurchase: 2-feb-12 Enter value for b_edition: 3 1 row created. SQL> insert into COLLEGE values ('&c_name',&c_code); Enter value for c_name: vv Enter value for c_code: 456 1 row created. SQL> insert into DEPARTMENT values(&d_no,'&d_name',&c_code); Enter value for d_no: 112 Enter value for d_name: cse Enter value for c_code: 456 1 row created. SQL> insert into FINEAMOUNT values(&b_bookid,'& b_latedate','& b_dateofreturn' ,& b_studid); Enter value for b_bookid: 444 Enter value for b_latedate: 2-jan-12 Enter value for b_dateofreturn: 4-feb-12 Enter value for b_studid: 002 1 row created.

SQL> insert into STUDENT values(&s_studid,'& s_name','& s_dob','& s_doj', &s_re gulation,'&s_gender',&s_deptno,'); Enter value for s_studid: 001 Enter value for s_name: mohan Enter value for s_dob: 1-jan-90 Enter value for s_doj: 1-jun-11 Enter value for s_regulation: 2008 Enter value for s_gender: m Enter value for s_deptno: 112 1 row created. 2. List down the full details of the student database. SQL>select * from student; S_STU S_NAME S_DOB S_DOJ S_REGU S_G S_DEPTNO S_MAILID -------------------------------------------------------------------------------------------------1001 ARUL 10-FEB-90 03-AUG-10 2008 M 1241 arul@gmail.com 12401 1000 10403 sivaram 12-FEB-90 02-SEP-08 2008 SIVA inigo 26-JUN-89 10-JUN-10 2008 11-DEC-90 13-SEP-08 2008 M M M 1241 sivarm@gmail.com 1241 siva@gmail.com 1243 inigo@gmail.com

4 rows selected. SQL> select * from bookdelivered; B_BOOKID B_NAME B_STUDID B_DATEOFR B_EDITION --------- ----- --------- --------- --------------------------------1101 rdbms 1000 27-FEB-10 6 4101 OS 1001 25-FEB-10 3 7301 dbms 20601 25-FEB-10 4 3 rows selected. SQL> select * from bookpurchased;

B_BOOKID B_NAME B_AU B_BOOKPR B_QUA B_STUDID B_DATEOFP B _EDITI --------- ----- ---------- ----------- ---------- --------- --------- ----------------------------------------1101 dbms cj date 450 3 12401 25-FEB-10 4 1102 os tenanbaum 470 1 10202 15-FEB-10 3 4101 dbms korbe 400 2 10201 21-FEB-10 8 7301 dbms elmasri 250 4 20601 22-FEB-10 10 4rows selected. SQL> select * from college; C_NAME C_CODE --------------- ------------------VV PSG TECH SVCE 3 rows selected. SQL> select * from department; D_NO D_NAME C_CODE --------- ---------- ----------------------2063 MECH 864 1241 CSE 864 2061 IT 206 1241 CIVIL 864 1022 ECE 864 1023 EEE 864 6 rows selected. SQL> select * from fineamount; B_BOOKID B_DATEOFR B_LATEDAT B_STUDID --------- --------- --------- --------1102 21-FEB-10 22-FEB-10 1001 1101 17-FEB-12 19-FEB-12 1000 4101 17-FEB-10 19-FEB-10 10202 7301 25-FEB-10 25-FEB-10 20601 4rows selected. 3. Modify the student id of college VV where department is CSE in student database. SQL> update student set s_studid=20604 where s_deptno in(select d_no from department where d_name='CSE'); 1 row updated. 4. Delete the record of the table book purchased where book has been purchased with 864 124 102

different editions. SQL> delete from bookpurchased where b_edition=10 and b_bookid=7301; 1 row deleted. 5. Display the student details in ascending order. SQL> select s_studid,s_name,s_deptno from student order by s_studid; S_STU S_NAME S_DOB S_DOJ S_REGU S_ S_DEPTNO S_MAILID -------------------------------------------------------------------------------------------------1000 SIVA 1001 ARUL 10403 inigo 26-JUN-89 10-JUN-10 2008 M 1241 siva@gmail.com 1241 arul@gmail.com 1243 inigo@gmail.com 1241 sivarm@gmail.com

10-FEB-90 03-AUG-10 2008 M 11-DEC-90 13-SEP-08 2008 m 2008 m

12401 sivaram 12-FEB-90 02-SEP-08 4 rows selected

6. Group all the department of the table college. SQL> select d_name from department group by d_name; D_NAME --------- ---------civil cse eee it mech 6 rows selected.

7. Display all the student of IT and MECH with college information. SQL> select s_studid,s_name,s_deptno from student where s_deptno in(select d_no from department where d_name='IT' or d_name='MECH');

S_STUDID S_NAME S_DEPTNO ---------------- -------------- -----------------20604 robin 2061 20603 palani 2063 8. Get the student information of CIVIL and ECE department present in library database. SQL> select s_studid,s_name from student where s_deptno=1241 or s_deptno=1022; S_STU S_NAME S_DOB S_DOJ S_REGU S_ S_DEPTNO S_MAILID -------------------------------------------------------------------------------------------------10403 inigo 11-DEC-90 13-SEP-08 2008 m 2008 m 1243 inigo@gmail.com 1241 sivarm@gmail.com

12401 sivaram 12-FEB-90 02-SEP-08 2 rows selected.

9. Display either the IT student or CSE student from VV. SQL> select s_studid,s_name from student where s_deptno=2061 or s_deptno=2062; S_STU S_NAME S_DOB S_DOJ S_REGU S_ S_DEPTNO S_MAILID -------------------------------------------------------------------------------------------------12401 sivaram 12-FEB-90 02-SEP-08 2008 m 1241 sivarm@gmail.com 1 row selected RESULT: Thus the DML queries were executed sucessfully.

EX NO: 3 DATE: AIM:

Nested queries and join queries

To study the concept of nested queries and join queries of oracle. INTRODUCTION: OBJECTIVE:SQL joins are used to query data from two or more tables, based on a relationship between certain columns in these tables. PROCEDURE:STEP 1: Start STEP 2: Create the table with its essential attributes. STEP 3: Insert attribute values into the table STEP 4: Execute different Commands and extract information from the table. STEP 5: Stop SQL COMMANDS:1. COMMAND NAME: INNER JOIN:The INNER JOIN keyword return rows when there is atleast one match in both tables. 2. COMMAND NAME: LEFT JOIN:The LEFT JOIN keyword returns all rows from the left table (table_name1), even if there are no matches in the right table (table_name2). 3. COMMAND NAME: RIGHT JOIN:The RIGHT JOIN keyword Return all rows from the right table (table_name2), even if there are no matches in the left table (table_name1). 4. COMMAND NAME : FULL JOIN:The FULL JOIN keyword return rows when there is a match in one of the tables.

SYNTAX:INNTER JOIN:SQL>SELECT column_name(s) FROM table_name1 INNER JOIN table_name2 ON table_name1.column_name=table_name2.column_name LEFT JOIN:SQL> SELECT column_name(s) FROM table_name1 LEFT JOIN table_name2 ON table_name1.column_name=table_name2.column_name RIGHT:SQL>SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo FROM Persons RIGHT JOIN Orders ON Persons.P_Id=Orders.P_Id ORDER BY Persons.LastName FULL JOIN:SQL>SELECT column_name(s) FROM table_name1 FULL JOIN table_name2 ON table_name1.column_name=table_name2.column_name QUERIES: 1. Display the department name which is present in each college. 2. Display all the student id details with book purchased information present in it. 3. List out the fine amount for the department of MECH students. 4. List out the authors of the book delivered by the students. 5. Display the quantity of books purchased by the department of MECH students. 6. List down the returned date of the purchased book with student id. 7. Change the case of the student into upper case. 8. List out the student name, department name and college name in alphabetical order. 9. List out the book id, book name, purchased date with department name

mentioned in it. 10. Modify the book name in delivered table from DBMS to DATABASE as per student database. 11. Order the student according to department number. 12. Delete a student details where date of birth must be 14-JAN-90. PROCEDURE:

1.Display the department name which is present in each college. SQL> select department.d_name,college.c_name from department inner join college on department.c_code=college.c_code; D_NAME MECH CSE IT TEXTILE ECE EEE C_NAME VV VV VV SVCE SVCE SVCE

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

9 rows selected. 2.Display all the student id details with book purchased information present in it. SQL> select student.s_studid,student.s_name,bookpurchased.b_bookid, bookpurchased.b_author, bookpurchased.b_bookprice from student inner join bookpurchased on bookpurchased.b_studid=student.s_studid;

S_STUDID S_NAME B_BOOKID B_AUTHOR 12401 Sivaram 20601 Arul raj 10202 Seva 10202 Seva 10203 Saran 1101 7301 4102 1102 4103 CJ DATE Elmasri Tenanbaum Trivedi

B_BOOKPRICE 450 250 470 420

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

TENANBAUM 470

3.List out ahe fine amount for the department of 'CSE' students. SQL> select b_studid,round(months_between (b_latedate,b_dateofreturn)*28)*5 as fineamt from fineamount where b_studid in (select s_studid from student where s_deptno=2062); B_STUDID FINEAMT --------- -------------------20602 15

4.List out the author of the book delivered by the students. SQL> select bookdelivered.b_studid,bookpurchased.b_bookid,bookpurchased.b_bookname,

bookpurchased.b_author from bookpurchased inner join bookdelivered on bookpurchased.b_studid = bookpurchased.b_studid; B_STUDID B_BOOKID B_BOO B_AUTHOR --------- --------- ----- ---------1000 1001 1000 1001 1101 DBMS CJ DATE 1101 DBMS CJ DATE 1102 OS TENANBAUM 1102 OS TENANBAUM

5.Display the quqntity of books purchased by the department of '' students. SQL> select b_studid,b_bookid,b_bookname,b_quantity from bookpurchased where b_studid in (select s_studid from student where s_deptno in(select d_no from department where d_name='MECH'));

B_STUDID 20603

B_BOOKID 7303

B_BOOKN OOPS

B_QUANTITY 2

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

6.List down the return date of the purchased book with student id. SQL> select bookpurchased.b_studid, bookpurchased.b_bookid, bookpurchased.b_bookname, fineamount.b_latedate from bookpurchased inner join fineamount on bookpurchased.b_studid; B_STUDID B_BOOKID B_BOO B_LATEDAT --------- --------- ----- ----------------------------10202 10202 20601 10203 4102 1102 7301 4103 OS OS DBMS OOPS 19-FEB-10 19-FEB-10 25-FEB-10 28-FEB-10 fineamount.b_studid=

7.Change the of the student into upper case. SQL> select upper (s_name) from student; UPPER(S_N ----------------ARUL SIVARAM SIVA INIGO 4 rows selected. 8.List out the student name, department name and college name in alphabetical order. SQL> select student.s_name, department.d_name, college.c_name from department inner join college on department.c_code = college.c_code join student on student.s_deptno = department.d_no order by student.s_name;

S_NAME arul sivaram siva

D_NAME CIVIL CSE CHEMICAL

C_NAME VV VV SVCE

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

9.List out the book id book name,purchased date with department name mentioned in it. SQL> select student.s_studid, student.s_name, bookpurchased.b_bookid, student join bookpurchased.b_bookname, bookpurchased.b_dateofpurchase, department.d_name from department on student.s_deptno = department.d_no join bookpurchased on bookpurchased.b_studid = student.s_studid; S_STUD 10201 12401 10202 12402 S_NAME B_BOOK B_BOOKN B_DATEOFP D_NAME arul sivaram siva inigo 4101 1101 4102 1102 DBMS DBMS OS OS 21-FEB-10 25-FEB-08 15-FEB-10 18-FEB-10 TEXTILE CIVIL ECE BIOMEDICAL

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

4 rows selected. 10.Modify the book name in book purchased table from 'DBMS' to 'DATABASE' as per stuent database. SQL> update bookdelivered set b_bookname='database' where b_bookid=1101; 1 row updated. SQL> select * from bookdelivered; B_BOOKID B_BOO 1101 4101 7301 1102 4102 DATABASE OS DBMS OS OS B_STUDID B_DATEOFR 1000 1001 20601 12402 10202 27-FEB-10 25-FEB-10 25-FEB-10 17-FEB-10 21-FEB-10 --------- ----- --------- --------- -------------------------------------

8 rows selected.

11.Order the students according to department number. SQL> select s_studid,s_name from student order by s_deptno; S_STUDID S_NAME --------- ------------------12401 SIVARAM 1000 SIVA 1001 ARUL 10403 INIGO 4 rows selected. 12.delete a student details where the date of birth must be '14-JAN-90. SQL> delete from student where s_dob='14-jan-90'; 1 row deleted. SQL> select s_studid,s_name,s_dob from student; S_STUDID S_NAME S_DOB --------- --------- --------------------1001 12401 10403 Arul Sivaram Inigo 10-FEB-90 12-FEB-90 11-DEC-90

3 rows selected.

JOIN QUERY: Procedure: 1. 2. 3. The JOIN keyword is used in an SQL statement to query data from two or more A primary key is a column (or a combination of columns) with a unique value for Each primary key value must be unique within the table. The purpose is to bind data tables, based on a relationship between certain columns in these tables. each row. together, across tables, without repeating all of the data in every table.

Different SQL JOINs 1) Inner Join: Return rows when there is at least one match in both tables. Syntax: SELECT column_name(s) FROM table_name1 INNER JOIN table_name2 ON table_name1.column_name=table_name2.column_name

2) Left Join: Return all rows from the left table, even if there are no matches in the right table Syntax: SELECT column_name(s) FROM table_name1 LEFT JOIN table_name2 ON table_name1.column_name=table_name2.column_name

3) Right Join: Return all rows from the right table, even if there are no matches in the left table Syntax: SELECT column_name(s) FROM table_name1 RIGHT JOIN table_name2 ON table_name1.column_name=table_name2.column_name

QUERY: Consider the "Persons" table: P_I LastName FirstName Address City Sandnes Sandnes Stavanger

d 1 Hansen Ola Timoteivn 10 2 Svendson Tove Borgvn 23 3 Pettersen Kari Storgt 20 "P_Id" column is the primary key in the "Persons" table. This means that no two rows can have the same P_Id. The P_Id distinguishes two persons even if they have the same name.

Next, the "Orders" table: O_Id OrderNo P_Id 1 77895 3 2 44678 3 3 22456 1 4 24562 1 5 34764 15 Note that the "O_Id" column is the primary key in the "Orders" table The "P_Id" column refers to the persons in the "Persons" table without using their names. The relationship between the two tables above is the "P_Id" column. 1) SQL INNER JOIN: SQL> SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo FROM Persons INNER JOIN Orders ON Persons.P_Id=Orders.P_Id ORDER BY Persons.LastName Output table: LastName Hansen Hansen Pettersen Pettersen FirstName Ola Ola Kari Kari OrderNo 22456 24562 77895 44678

2) SQL LEFT JOIN: SQL> SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo FROM Persons LEFT JOIN Orders ON Persons.P_Id=Orders.P_Id ORDER BY Persons.LastName Output table: LastName Hansen Hansen Pettersen Pettersen Svendson FirstName Ola Ola Kari Kari Tove OrderNo 22456 24562 77895 44678

3) SQL RIGHT JOIN: SQL> SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo FROM Persons RIGHT JOIN Orders ON Persons.P_Id=Orders.P_Id ORDER BY Persons.LastName Output table: LastName Hansen Hansen Pettersen Pettersen FirstName Ola Ola Kari Kari OrderNo 22456 24562 77895 44678 34764

RESULT: Thus the concept of nested queries and join queries of oracle were studied and executed. .

EX NO: 4 AIM:

Views

To study the concept of Views. INTRODUCTION: A view is logical table based on a table or another view and acts as a window through which data on tables can be viewed or changed. A view does not contain data. The definition of the view is stored in the data dictionary. The tables on which a view is based are called base tables. We can see the definition of the view in USER_VIEWS data dictionary table.

ADVANTAGES OF VIEW: Views restrict access to the data because the view can display selective column from table. Views can be used to make simple queries to retrieve the results of complicated queries 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. There are two classifications for views: simple and complex. The basic difference is related to the DML (INSERT, DELETE, and UPDATE) operations. CREATING A VIEW: A view can be created using the following statement. Syntax: CREATE VIEW view name as SELECT column name, column name FROM table name WHERE column name = < query expression>; MODIFYING A VIEW: With the OR REPLACE option, a view can be created even if one exists with this name already, thus replacing the old version of the view for its owner. This means that the view can be altered without dropping, re-creating, and re granting object privileges.

Syntax: CREATE OR REPLACE VIEW view name as SELECT column name, column name FROM table name WHERE column name = < query expression>; DROPPING A VIEW: The view can be removed using the following statement: Syntax: DROP VIEW view name; This statement removes the view definition from the database. Dropping views has no effect on the tables on which the view was based. Views or other applications based on deleted views become invalid. Only the creator or a user with the DROP ANY VIEW privilege can remove a view. SEQUENCE: A sequence is a user created data base object that can be shared by multiple users to generate unique integers. A typical usage for sequences is to create a primary key value, which must be unique for each row. The sequence is generated and incremented (or decremented) by an internal Oracle routine. This can be a time-saving object because it can reduce the amount of application code needed to write a sequence generating routine. CREATING A SEQUENCE: The following statement is used to create a sequence to generate sequential numbers automatically: Syntax: CREATE SEQUENCE sequence [ INCREMENT BY n ] [ START WITH n ] [ MAX VALUE n ] [ MIN VALUE n ] [ {CYCLE | NO CYCLE} ] [ {CACHE | NO CACHE} ]; DROPPING A SEQUENCE: The following statement is used to remove a sequence from data dictionary. You must be the

owner of the sequence or have the DROP ANY SEQUENCE privilege to remove it. Syntax: DROP SEQUENCE sequence name INDEX: An Oracle server index is a schema object that can speed up the retrieval of rows by using a pointer. Indexes can be created explicitly or automatically. An index provides direct and fast access to rows in a table. Its purpose is to reduce the necessity of disk I/O by using an indexed path to locate data quickly. The index is used and maintained automatically by the Oracle server. Once an index is created, no direct activity is required by the user. Indexes are logically and physically independent of the table they index. This means that they can be created or dropped at any time and have no effect on the base tables or other indexes. CREATING AN INDEX: An index can be created by using the following statement: Syntax: CREATE INDEX index name ON table name (column name [,column name]); REMOVING AN INDEX: We cannot modify indexes. To change an index, we have to drop it and then re-create it. The owner of the index or the user with DROP ANY INDEX privilege only can drop an index. The following statement is used to remove an index: Syntax: DROP INDEX index name; SYNONYMS: To refer a table owned by another user, we need to prefix the table name with the name of the user who created it followed by a period. Creating a synonym eliminates the need to qualify the object name with the schema and provides you with an alternative name for a table, view, sequence, procedure, or other objects. This method can be especially useful with lengthy object names, such as views. CREATING A SYNONYM: A synonym can be created using the following statement: Syntax:

CREATE [PUBLIC] SYNONYM synonym-name FOR object; Here the object refers to the object for which the synonym is created and public creates a synonym accessible to all users.

DROPPING A SYNONYM: To drop a synonym, the following statement is used. Only the database administrator can drop a public synonym. Syntax: DROP SYNONYM synonym-name; PROCEDURE: 1.Create view for all the tables which has been created. 2. Display the records of information of college with department name specified. 3. Display the student details with college name specified. 4. Display the return date and the date of return in the IT dept. 5. List down the student details passing in the year 2010. 6. List down the quantity of each books. 7. Calculate the amount of price for the book which was specified. 8. Display the same book of authors which has been entered. 9. Create an index for the book purchase table. 10. Create sequence for student details. 11. Create the synonyms for college table. 12. Display the cluster id of the table. 13. Display the index position of the table which has been created. 14. Display the sequence number. QUERIES: 1. Create view for all the tables which has been created. SQL> create view v_student as select *from student; View created.

SQL>desc v_student Name S_NAME S_STUDID S_DEPTNO S_MAILID S_DOB S_DOJ S_REGULATION S_GENDER Null? Type VARCHAR2(10) NUMBER(10) NUMBER(10) VARCHAR2(20) DATE DATE NUMBER(10) VARCHAR2(10)

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

SQL> create view v_college as select *from college; View created. SQL> desc v_college; Name C_NAME C_CODE View created. SQL> desc v_department; Name D_NAME D_NO C_CODE Null? Type VARCHAR2(20) NUMBER(20) NUMBER(10) Null? Type VARCHAR2(20) NUMBER(10)

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

SQL> create view v_department as select *from department;

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

SQL> create view v_bookpurchase as select *from bookpurchase;

View created. SQL> desc v_bookpurchase; Name B_BOOKID B_NAME B_AUTHOR B_QUANTITY B_BOOKPRICE B_STUDID B_DATEOFPURCHASE B_EDITION Null? Type NUMBER(10) VARCHAR2(15) VARCHAR2(15) NUMBER(10) NUMBER(10) NUMBER(10) DATE NUMBER(10)

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

SQL> create view v_bookdelivered as select *from bookdelivered; View created. SQL> desc v_bookdelivered; Name B_BOOKID B_NAME B_DATEOFRETURN B_STUDID Null? Type NUMBER(10) VARCHAR2(20) DATE NUMBER(10)

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

SQL> create view v_fineamount as select *from fineamount; View created. SQL> desc v_fineamount;

Name B_LATEDATE B_DATEOFRETURN B_BOOKID B_STUDID B_CODE

Null?

Type DATE DATE NUMBER(10) NUMBER(10) NUMBER(10)

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

2. Display the records of information of college with department name specified. SQL> select v_college.c_name,v_college.c_code,v_department.d_name from v_college full outer join v_department on v_college.c_code=v_department.c_code; C_NAME C_CODE VV VV VV SVCE 456 456 456 124 D_NAME IT MECH CSE CIVIL

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

3. Display the student details with college name specified. SQL> select v_college.c_name,v_student.s_name,v_student.s_studid,v_department.d_no from v_department join v_college on v_college.c_code = v_department.c_code join v_student on v_student.s_deptno =v_department.d_no;

C_NAME VV VV SVCE SVCE

S_NAME SIVA ARUL SIVARAM MATHAN

S_STUDID 10202 10203 12401 12403

D_NO 1022 1023 1241 1243

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

4. Display the return date and the date of return in the IT dept. SQL> select b_latedate,b_dateofreturn from v_fineamount where b_studid in(select s_studid from v_student where s_deptno in(select d_no from v_department where d_name='IT'')); B_LATEDATE B_DATEOFRETURN -------------------- ----------------------------28-FEB-10 27-FEB-10

5. List down the student details passing in the year 2010. SQL> select s_name,s_studid,s_deptno,s_doj,s_yearofpassing from student where s_yearofpassing = '2012'; S_NAME ARUL MATHAN S_STUDID 10201 12401 S_DEPTNO 1022 1241 S_DOJ 10-SEP-08 02-SEP-08 S_YEAROFPASSING 2012 2012 -------------- ------------------- ------------------ -------------------- --------------------------------

6. List down the quantity of each books. SQL> select b_name,b_author,b_quantity from v_bookpurchase; B_NAME DBMS DBMS OS OOPS B_AUTHOR KORBE ELMASRI TENANBAUM TRIVEDI B_QUANTITY 2 4 1 1 ----------------- ---------------------------- -----------------------

7. Calculate the amount of price for the book which was specified. SQL> select sum(b_bookprice) from v_bookpurchase where b_name='DBMS'; SUM(B_BOOKPRICE) --------------------------------1100 8. Display the same book of authors which has been entered. SQL> select b_name,b_author from v_bookpurchase;

B_NAME DBMS DBMS OS OOPS

B_AUTHOR KORBE ELMASRI TENENBAUM TRIVEDI

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

9. Create an index for the book purchase table. SQL> create index bookid on bookpurchase(b_bookid); Index created. 10. Create sequence for student details. SQL>create sequence v_sequence_no_seq increment by 1 start with 1 nomaxvalue; nocycle nocache; Sequence created. 11. Create the synonyms for college table. SQL> create [public] synonym s_college for alice.college; Synonym created. 12. Display the cluster id of the table. SQL> create cluster bookdetails 2 (bookid number(10)) 3 SIZE 512 4 STORAGE (initial 100K next 50K); Cluster created. SQL> CREATE INDEX idx_bookdetails ON CLUSTER bookdetails; Index created. SQL> CREATE TABLE book_detail CLUSTER bookdetails (b_bookid) AS SELECT * FROM

bookpurchase where b_bookid=1011; Table created. 13. Display the index position of the table which has been created. SQL> select ic.index_name,ic.column_name,ic.column_position col_pos,ix.uniqueness from user_indexes ix, user_ind_columns ic where ic.index_name=ix.index_name AND ic.table_name = 'BOOKPURCHASE'; INDEX_NAME COLUMN_NAME COL_POS BOOKID B_BOOKID 1 UNIQUENESS NONUNIQUE

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

14. Display the sequence number. SQL>select *from user_sequences; SEQ_NAME v_sequence_no_seq MIN_VAL 1 MAX_VAL INCREMENT_BY 1.0000E+27 1 LAST_NUMBER 1

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

RESULT: Thus the concept of views were studied.

EX NO: 5

CONTROL STRUCTURES IN PL/SQL

AIM: To write simple programs using pl/sql language. PL/SQL: PL/SQL is a procedural language that oracle developed as an extension to standard SQL to provide a way to execute procedural logic on the database. A simple PL/SQL block: Each PL/SQL program consist of SQL and PL/SQL statements which form a PL/SQL block. The three sections are: The declarative section. The executive section. The exception handling section. Declaration section: The declaration section of a pl/sql block starts with reserved keyword DECLARE. This section is optional and is used to declare any placeholders like variables, constants, record sand cursors, which are used to manipulate data in the execution section. Placeholders may be any of variables, constants and records which stores data temporarily. Cursors are also declared in this section. Execution section: The execution section of pl/sql block starts with the reserved keyword BEGIN and ends with END. This is mandatory section and is the section where the program logic is written to perform any task.the programmatic constructs like loops, conditional statements and sql. Exceptional section: The exceptional sectional of a pl/sql block starts with the reserved keyword EXCEPTION. This section is optional. Any errors in the program can be handled in this section. If the pl/sql block contains exceptions that cannot be handled, the block terminates abruptly with errors. Every statement in the above three sections must end with a semicolon; pl/sql blocks can be nested within other pl/sql blocks.

Syntax: DECLARE Variable declaration BEGIN Program execution EXECPTION Exception handling END; PL/SQL variables: These are placeholders that store the values that can change through the pl/sql block. Syntax: Variable_name datatype[NOT NULL:=value]; We can directly assign values to variables. Syntax: variable_name:=value; PROCEDURE: The procedure is a program that performs an action and does not return a value (outside of IN OUT and OUT parameters). A procedure has two parts: the specification (spec for short) and the body. The procedure spec begins with the keyword PROCEDURE and ends with the procedure name or a parameter list. Parameter declarations are optional. Procedures that take no parameters are written without parentheses. The declarative part contains local declarations, which are placed between the keywords IS and BEGIN. The keyword DECLARE, which introduces declarations in an anonymous PL/SQL block, is not used. The executable part contains statements, which are placed between the keywords BEGIN and EXCEPTION (or END). At least one statement must appear in the executable part of a procedure. The NULL statement meets this requirement. The exceptionhandling part contains exception handlers, which are placed between the keywords EXCEPTION and END.

Syntax: CREATE [OR REPLACE] PROCEDURE procedure_name [ (parameter [,parameter]) ] IS [declaration_section] BEGIN executable_section [EXCEPTION exception_section] END [procedure_name]; Example: PROCEDURE hire_employee (emp_id INTEGER, name VARCHAR2) IS BEGIN INSERT INTO employee VALUES (emp_id, name, 1000); END hire_employee; Execute a PL/SQL function or procedure. Syntax: EXEC statement EXEC [:bind_variable :=] package.procedure; EXEC [:bind_variable :=] package.function(parameters); The length of the EXEC command cannot exceed the length defined by SET LINESIZE. If the EXEC command is too long to fit on one line, use the SQL*Plus continuation character (a hyphen) Difference between stored procedures and functions:

Only functions can Return value ( to be precise: using the return keyword). Procedures can use Return keyword but without any value being passed.

Functions could be used in SELECT statement, provided they dont do any data manipulation Functions must return a value, but for procedure it is not compulsory. A function can have only in parameters, while stored procedures may have out or in out Procedure is a sub program written to perform a set of actions and returns multiple values

and also should not have any OUT or IN OUT parameters.


parameters.

using out parameters or return no value at all.

FUNCTIONS: The function is a program that might perform an action and does return a value. A function is a subprogram that computes a value. Like a procedure, a function has two parts: the spec and the body. The function spec begins with the keyword FUNCTION and ends with the RETURN clause, which specifies the datatype of the return value. Parameter declarations are optional. Functions that take no parameters are written without parentheses. The function body begins with the keyword IS (or AS) and ends with the keyword END followed by an optional function name. The function body has three parts: a declarative part, an executable part, and an optional exception-handling part. The declarative part contains local declarations, which are placed between the keywords IS and BEGIN. The keyword DECLARE is not used. The executable part contains statements, which are placed between the keywords BEGIN and EXCEPTION (or END). One or more RETURN statements must appear in the executable part of a function. The exception-handling part contains exception handlers, which are placed between the keywords EXCEPTION and END. Syntax: CREATE [OR REPLACE] FUNCTION function_name [ (parameter [,parameter]) ]AS [declaration_section] BEGIN executable_section RETURN END [function_name]; QUERIES: 1. Write a program to display the name of the polygon from the given no. of sides.

2. Write a program to find the nth power of the value x. 3. Program to find the square root of given number without using the built in function. 6. Write a program to check whether the given name is palindrome or not. 7. Create a function for factorial of n numbers.

PROCEDURE: 1. Program to display Multiplication table: 1 declare 2 3 5 6 7 8 9* end; OUTPUT: SQL> / Enter value for n: 5 old 5: n:=&n; new 5: 5*1=5 5*2=10 5*3=15 5*4=20 5*5=25 5*6=30 5*7=35 5*8=40 5*9=45 5*10=50 PL/SQL procedure successfully completed. 2. Program to find the nth power of the value x. SQL> declare 2 x number:=&x; n:=5; i number(2); n number(2); n:=&n; for i in 1..10 loop DBMS_output.put_line(n || '*' || i ||'='||n*i); end loop;

4 begin

3 n number:=&n; 4 z number:=1; 5 begin 6 for i in 1..n loop 7 z:=z*x; 8 end loop; 9 dbms_output.put_line('The '||to_char(n)||'th power of '||to_char(x)||' is: '||z); 10 end; 11 / OUTPUT:Enter value for x: 3 Enter value for n: 4 The 4th power of 3 is: 81 PL/SQL procedure successfully completed. 3. Write a program to check whether the given name is palindrome or not. SQL> create or replace procedure p1(c varchar) 2 is 3 len number; 4 n varchar(20); 5 begin 6 len:=length(c); 7 len:=length(c); 8 while(len>0) 9 loop 10 n:=n||substr(c,len,1); 11 len:=len-1; 12 end loop; 13 if c=n then 14 dbms_output.put_line('The given is palindrome: '||c); 15 else 16 dbms_output.put_line('The given is not a palindrome: '||c); 17 end if; 18 end; 19 /

Procedure created.

OUTPUT:SQL> exec p1('MALAYALAM'); The given is palindrome: MALAYALAM PL/SQL procedure successfully completed. 5. Generate a sum of series for a given number. SQL> create or replace procedure p2(n number) 2 is 3 s number:=0; 4 i number:=0; 5 begin 6 for i in 0..n loop 7 s:=s+i; 8 end loop; 9 dbms_output.put_line('The sum is: '||s); 10 end; 11 / Procedure created. OUTPUT:SQL> exec p2(3); The sum is: 6 PL/SQL procedure successfully completed. 6. Check whether the number is Armstrong or not. SQL> create or replace procedure p3(num number) 2 is 3 num1 number(5); 4 rem number(5); 5 s number(5):=0; 6 begin 7 num1:=num; 8 while(num1>0)

9 loop 10 rem:=mod(num1,10); 11 s:=s+power(rem,3); 12 num1:=trunc(num1/10); 13 end loop; 14 if(s=num) then 15 dbms_output.put_line(num||' is an Armstrong number'); 16 else 17 dbms_output.put_line(num||' is not an Armstrong number'); 18 end if; 19 end; 20 / Procedure created. OUTPUT:SQL> exec p3(370); 370 is an Armstrong number PL/SQL procedure successfully completed. 7. Create a function for factorial of n numbers. SQL>create or replace function fact(n number)return number 2 is 3 i number; 4 f number:=1; 5 begin 6 for i in 1..n loop 7 f:=f*i; 8 end loop; 9 return f; 10 end; 11 / Function created. OUTPUT:SQL> select fact(4) from dual; FACT(4) ----------

24

RESULT: Thus simple programs were implemented using pl/sql language.

Ex No: 6
AIM:

Front End Tools

To study the different front end tools.

Introduction: Visual Studio is a complete set of development tools for building ASP.NET Web applications,

XML Web Services, desktop applications, and mobile applications. Visual Basic, Visual C++, Visual C#, and Visual J# all use the same integrated development environment (IDE), which allows them to share tools and facilitates in the creation of mixed-language solutions. In addition, these languages leverage the functionality of the .NET Framework, which provides access to key technologies that simplify the development of ASP Web applications and XML Web Services. Visual Studio Highlights This section contains information about some of the latest tools and technologies available in this release of Visual Studio. Visual Studio Tools For Office Microsoft Visual Studio 2010 Tools for the Microsoft Office System can help you create solutions by extending Word 2010 documents and Excel 2010 workbooks using Visual Basic and Visual C#. Visual Studio Tools for Office includes new Visual Studio projects for creating code behind Word documents, Word templates, Excel workbooks, and Excel templates. Visual Web Developer Visual Studio features a new Web page designer named Visual Web Developer that includes many enhancements for creating and editing ASP.NET Web pages and HTML pages. It provides a simpler, faster way to create Web Forms pages than in Visual Studio .NET 2010. Visual Web Developer features improvements in all areas of Web site development. You can create and maintain Web sites as local folders, in Internet Information Services (IIS), or on an FTP or SharePoint server. The Visual Web Developer designer supports all ASP.NET enhancements, including nearly two dozen new controls that simplify many Web development tasks. For more information, Smart Device Applications The Visual Studio integrated environment includes tools for targeting devices such as PDAs and Smartphones. Improvements include Visual C++ tools and native device runtimes, managed designers that provide improved platform-specific WYSIWYG and multiple form factor support, a new emulator, data handling tools similar to the desktop, and end-user deployment projects that eliminate the manual editing of .inf files. Web Forms Web Forms are an ASP.NET technology that you use to create programmable Web pages. Web

Forms render themselves as browser-compatible HTML and script, which allows any browser on any platform to view the pages. Using Web Forms, you create Web pages by dragging and dropping controls onto the designer and then adding code, similar to the way that you create Visual Basic forms. For more information Windows Forms Windows Forms is for creating Microsoft Windows applications on the .NET Framework. This framework provides a clear, object-oriented, extensible set of classes that enables you to develop rich Windows applications. Additionally, Windows Forms can act as the local user interface in a multi-tier distributed solution. For more information XML Web Services XML Web Services are applications that can receive requests and data using XML over HTTP. XML Web Services are not tied to a particular component technology or object-calling convention and can therefore be accessed by any language, component model, or operating system. In Visual Studio, you can quickly create and include XML Web Services using Visual Basic, Visual C#, JScript, or ATL Server. For more information, XML Support Extensible Markup Language (XML) provides a method for describing structured data. XML is a subset of SGML that is optimized for delivery over the Web. The World Wide Web Consortium (W3C) defines XML standards so that structured data will be uniform and independent of applications. Visual Studio fully supports XML, providing the XML Designer to make it easier to edit XML and create XML schemas. RESULT: Thus the different front end toools are studied. Ex No: 7 AIM: To design forms using ASP.NET. Processing a Simple Form Now that you have a basic understanding of ASP.NET page FORMS

structure, the languages VB.NET and C#, and HTML controls, let's put everything together and create a simple ASP.NET application.

The application that we will create, in VB.NET and C#, will be a simple survey form that uses the following HTML controls:

HtmlForm HtmlButton HtmlInputText HtmlSelect

Let's begin by creating a new file within your favorite code editor. The following code creates the visual interface for the survey:

Example 4.1. SimpleForm.aspx (excerpt) <html> <head> ... </head> <body> <form runat="server"> <h2>Take the Survey!</h2> <p>Name:<br /> <input type="text" id="txtName" runat="server" /></p> <p>Email:<br /> <input type="text" id="txtEmail" runat="server" /></p> <p>Which server technologies do you use?<br /> <select id="servermodel" runat="server" multiple="true"> <option>ASP.NET</option> <option>PHP</option> <option>JSP</option> <option>CGI</option>

<option>Coldfusion</option> </select></p> <p>Do you like .NET so far?<br /> <select id="likedotnet" runat="server"> <option selected>Yes</option> <option>No</option> </select></p> <p><button id="myButton" OnServerClick="Click" runat="server"> Confirm</button></p> </form> </body>
</html>

When users click the button, we'll simply display responses in their browsers. In a real application Code: protected void Button1_Click(object sender, EventArgs e) { Response.Write("Your name is: " + txtName.Value + "<br />"); Response.Write("Your email is: " + txtEmail.Value + "<br />"); Response.Write("You like to work with: " + servermodel.Value + "<br />");

their

Response.Write("You like .NET: " + likedotnet.Value); }

Basic Web Controls The basic Web controls perform the on-screen layout of a Web page, and mirror in many ways the HTML controls that are based on regular HTML. However, they offer some new refinements and enhancements, and should be used in place of HTML whenever possible. In this section, we'll look at the controls in this group, namely: Label: The easiest way to display static text on your page is simply to add the text to the body of the page without enclosing it in any tag. However, if you want to modify the text displayed on a page from ASP.NET code, you can display your text within a Label control. Here's a typical example: <asp:Label id="lblMessage" Text="" runat="server" /> The following code sets the Text property of the Label control to display the text "Hello World": TextBox: The TextBox control is used to create on screen a box in which the user can type or read standard text. Label TextBox Button Image ImageButton LinkButton HyperLink RadioButton RadioButtonList CheckBox CheckBoxList DropDownList ListBox

Button:

By default, the Button control renders the same form submit button that's rendered by the HTML <input type="Submit"> tag. When a button is clicked <asp:Button id="btnSubmit" Text="Submit" runat="server" OnClick="WriteText" /> <asp:Label id="lblMessage" runat="server" />

LinkButton A LinkButton control renders a hyperlink on your page <asp:HyperLink id="myLink" NavigateUrl="http://www.example.com/" ImageUrl="myButton.gif" runat="server">My Link</asp:HyperLink>

RadioButton: You can add individual radio buttons to your page one by one, using the RadioButton control. Radio buttons are grouped together using the GroupName property. Only one RadioButton control from each group can be selected at a time. <asp:RadioButton id="radSanDiego" GroupName="City" Text="San Diego" runat="server" /> <asp:RadioButton id="radBoston" GroupName="City" Text="Boston" runat="server" /> <asp:RadioButton id="radPhoenix" GroupName="City" Text="Phoenix" runat="server" /> <asp:RadioButton id="radSeattle" GroupName="City" Text="Seattle" runat="Server" /> The main event associated with RadioButtons is the CheckChanged event; which can be handled with the OnCheckChanged attribute. RadioButtonList: Like the RadioButton control, the RadioButtonList control represents radio buttons. However, the RadioButtonList control represents a list of radio buttons and uses more compact syntax.

Here's an example: <asp:RadioButtonList id="radlFavColor" runat="server"> <asp:ListItem Text="Red" Value="red" /> <asp:ListItem Text="Blue" Value="blue" /> <asp:ListItem Text="Green" Value="green" /> </asp:RadioButtonList>

CheckBox: You can use a CheckBox control to represent a choice that can be only a yes (checked) or no (unchecked) value. <asp:CheckBox id="chkQuestion" Text="I like .NET!" runat="server" /> CheckBoxList: As you may have guessed, the CheckBoxList control represents a group of check boxes; it's equivalent to using several CheckBox controls in row: <asp:CheckBoxList id="chklFavDrinks" runat="server"> <asp:ListItem Text="Pizza" Value="pizza" /> <asp:ListItem Text="Tacos" Value="tacos" /> <asp:ListItem Text="Pasta" Value="pasta" /> </asp:CheckBoxList> DropDownList: A DropDownList control is similar to the HTML <select> tag. The DropDownList control allows you to select one item from a list using a drop-down menu. <asp:DropDownList id="ddlFavColor" runat="server"> <asp:ListItem Text="Red" value="red" /> <asp:ListItem Text="Blue" value="blue" /> <asp:ListItem Text="Green" value="green" /> </asp:DropDownList> List Box: A ListBox control equates to the HTML <select> tag with the size attribute set to 2 or more. The ListBox control allows you to

select items from a multiline menu. If you set the SelectionMode attribute to Multiple <asp:ListBox id="listTechnologies" runat="server" SelectionMode="Multiple"> <asp:ListItem Text="ASP.NET" Value="aspnet" /> <asp:ListItem Text="JSP" Value="jsp" /> <asp:ListItem Text="PHP" Value="php" /> <asp:ListItem Text="CGI" Value="cgi" /> <asp:ListItem Text="Coldfusion" Value="cf" /> </asp:ListBox> Example: Check Box and Text Box: Home Phone: Work Phone: Same as home phone code: protected void Check(object sender, EventArgs e) { if (check1.Checked) { work.Text = home.Text; } else { work.Text=""; } } Output: Home Phone: Work Phone: Same as home phone

Check box list:

CheckBoxList in ASP.NET 4 , C# Which country will you prefer for holidays? India Singapur Switzerland Australiya You have selected the following countries: India Code: protected void Page_Load(object sender, EventArgs e) { string msg = "You have selected the following countries:<br />"; if (ckeckboxlist1.Items[0].Selected) { msg = msg + ckeckboxlist1.Items[0].Text + "<br />"; } if (ckeckboxlist1.Items[1].Selected) { msg = msg + ckeckboxlist1.Items[1].Text + "<br />"; } if (ckeckboxlist1.Items[2].Selected) { msg = msg + ckeckboxlist1.Items[2].Text + "<br />"; } if (ckeckboxlist1.Items[3].Selected) { msg = msg + ckeckboxlist1.Items[3].Text + "<br />"; } Message.Text = msg; }

protected void ckeckboxlist1_SelectedIndexChanged(object sender, EventArgs e) { }

Drop Downlist:

you are selectedItem 2

Code: protected void submit(object sender, EventArgs e) { mess.Text = "you are selected" + drop1.SelectedItem.Text; } Radio button list: Item 1 Item 2 Item 3 Item 4 Output Item 1 Item 2 Item 3 Item 4

you are selectedItem 1

Code: protected void submit(object sender, EventArgs e) { Label1.Text = "you are selected" + radiolist1.SelectedItem.Text; }

RESULT: Thus the forms were designed using ASP.NET

Ex No: 8

Triggers

AIM: To implement triggers. INTRODUCTION: A trigger is a special PL/SQL procedure that fires, or executes, in response to a specific triggering event. For example, you might write a trigger to enforce a business rule on INSERT statements on track user logons. A trigger has three parts:
A header line that defines the triggering event An optional WHEN clause that restricts the trigger's firing to a specific condition (for example,

a particular table, maintain referential integrity in a distributed database, or

the trigger fires only when salary is greater than $50,000)


The actual trigger code itself

This chapter tests your ability to (among other things) define triggers for a variety of events, work with correlation variables (special pseudo-column names that represent things like the old and new values of a column), and use triggers to implement business logic. A database trigger is a block of code that is automatically executed in response to certain events. Triggers are executed implicitly whenever the triggering event happens. The triggering event is either a INSERT, DELETE, or UPDATE command. The timing can be either BEFORE or AFTER, INSTEAD OF trigger The trigger can be either row-level or statement-level, where the former fires once for each row affected by the triggering statement and the latter fires once for the whole statement. Syntax: CREATE [OR REPLACE] TRIGGER [schema.]trigger {BEFORE | AFTER} {DELETE | INSERT | UPDATE [OF column [, column] ...]} [OR {DELETE | INSERT | UPDATE [OF column [, column] ...]}]... ON [schema.]table [ [REFERENCING { OLD [AS] old [NEW [AS] new] | NEW [AS] new [OLD [AS] old] } ] FOR EACH ROW [WHEN (condition)] ] pl/sql_block OR REPLACE: Recreates the trigger if it already exists. You can use this option to change the definition of an existing trigger without first dropping it.

SCHEMA: Schema to contain the trigger. If you omit schema, Oracle creates the trigger in your own schema. TRIGGER: is the name of the trigger to be created. BEFORE: Indicates that Oracle fires the trigger before executing the triggering statement. AFTER :Indicates that Oracle fires the trigger after executing the triggering statement. DELETE: Indicates that Oracle fires the trigger whenever a DELETE statement removes a row from the table . INSERT: Indicates that Oracle fires the trigger whenever an INSERT statement adds a row to table. UPDATE...OF: Indicates that Oracle fires the trigger whenever an UPDATE statement changes a value in one of the columns specified in the OF clause. If you omit the OF clause, Oracle fires the trigger whenever an UPDATE statement changes a value in any column of the table. ON: Specifies the schema and name of the table on which the trigger is to be created. If you omit schema, Oracle assumes the table is in our own schema. You cannot create a trigger on a table in the schema SYS. REFERENCING: Specifies correlation names.You can use correlation names in the PL/SQL block and WHEN clause of a row trigger to refer specifically to old and new values of the current row. The default correlation names are OLD and NEW. If your row trigger is associated with a table named OLD or NEW, you can use this clause to specify different correlation names to avoid confusion between the table name and the correlation name. FOR EACH ROW: Designates the trigger to be a row trigger. Oracle fires a row trigger once for each row that is affected by the triggering statement and meets the optional trigger constraint defined in the WHEN clause.If you omit this clause, the trigger is a statement trigger.Oracle fires a statement trigger only once when the triggering statement is issued if the optional trigger constraint is met. WHEN:

Specifies the trigger restriction. The trigger restriction contains a SQL condition that must be cannot satisfied for Oracle to fire the trigger. This condition must contain correlation names and contain a query.You can only specify a trigger restriction for a row trigger.Oracle evaluates

this condition for each row affected by the triggering statement. pl/sql_block The PL/SQL block that Oracle executes to fire the trigger. Some important points to note:
You can create only BEFORE and AFTER triggers for tables. (INSTEAD OF triggers are only

available for views; typically they are used to implement view updates.) You may specify up to three triggering events using the keyword OR. Furthermore, UPDATE can be optionally followed by the keyword OF and a list of attribute(s) in <table_name>. If present, the OF clause defines the event to be only an update of the attribute(s) listed after OF. Here are some examples: ... INSERT ON R ... ... INSERT OR DELETE OR UPDATE ON R ... ... UPDATE OF A, B OR INSERT ON R ... If FOR EACH ROW option is specified, the trigger is row-level; otherwise, the trigger is Only for row-level triggers: The special variables NEW and OLD are available to refer to new and old tuples

statement-level. . 1.

respectively. Note: In the trigger body, NEW and OLD must be preceded by a colon (" :"), but in the WHEN clause, they do not have a preceding colon! See example below. 2. 3. The REFERENCING clause can be used to assign aliases to the variables NEW and OLD. A trigger restriction can be specified in the WHEN clause, enclosed by parentheses. The

trigger restriction is a SQL condition that must be satisfied in order for Oracle to fire the trigger. This condition cannot contain subqueries. Without the WHEN clause, the trigger is fired for each row. <trigger_body> is a PL/SQL block, rather than sequence of SQL statements. Oracle has placed certain restrictions on what you can do in <trigger_body>, in order to avoid situations where

one trigger performs an action that triggers a second trigger, which then triggers a third, and so on, which could potentially create an infinite loop. The restrictions on <trigger_body> include: oYou cannot modify the same relation whose modification is the event triggering the trigger. You cannot modify a relation connected to the triggering relation by another constraint such as a foreign-key constraint.. 1.Simple Example for using Trigger in PL/SQL set serveroutput on create or replace trigger t before insert on emp for each row begin DBMS_OUTPUT.PUT_LINE('Inserting given records'); end; Copy the output: Trigger created. SQL> insert into emp values(3,'ppp',1750); Inserting given records... Example 2: set serveroutput on CREATE OR REPLACE TRIGGER t1 BEFORE INSERT OR UPDATE OF name OR DELETE ON emp BEGIN CASE

WHEN INSERTING THEN DBMS_OUTPUT.PUT_LINE('Inserting'); WHEN UPDATING('name') THEN DBMS_OUTPUT.PUT_LINE('Updating name'); WHEN DELETING THEN DBMS_OUTPUT.PUT_LINE('Deleting'); END CASE; END; Example Front-end and Back-end using trigger concepts: In General we take input values what we had entered in textboxes and calculating displaying the result through front end coding.But this may not be secure to your data.so calculation have to be done at the Back end in Oracleserver using Triggers.Trigger will take input of inserted values from a table,after calculating them it insert the result at the particular result column. Back -end- Trigger: create or replace trigger t8 before insert no on emp for each row when(new.no > 100) BEGIN RAISE_APPLICATION_ERROR ( num => -20000, msg => 'Cannot enter number'); END; Front-End-application: emp no emp name 3 asd

Insert Record Inserted emp no emp name 101 asd Insert ORA-20000: Cannot enter number ORA-06512: at "ANANTH.T7", line 2 ORA-04088: error during execution of trigger 'ANANTH.T7' Front-End Code: OleDbConnection con = new OleDbConnection("provider=MSDAORA ;User Id=ananth;password=vvcoe;Data source=orcl;"); OleDbCommand cmd = new OleDbCommand(); protected void Button1_Click(object sender, EventArgs e) { string eno; string ename; eno = TextBox1.Text.Trim(); ename = TextBox2.Text.Trim(); cmd.Connection = con; con.Open(); cmd.CommandText = "insert into tbl_emp values(?,?)"; cmd.Parameters.Add("no", TextBox1.Text.Trim()); cmd.Parameters.Add("name", TextBox2.Text.Trim()); OleDbTransaction t8 = con.BeginTransaction(); cmd.Transaction = t8; cmd.ExecuteNonQuery(); t8.Commit(); Response.Write("Record Inserted"); con.Close(); } Result: Thus triggers were implemented.

Exp. no.9 Date:

REPORTS

AIM: To develop reports using VB.

Procedure: step 1: Drag and drop necessary items from toolbox i.e. report viewer, script manager and object data source. Step 2: From report viewer, choose Design a new report to connect backend(Oracle) data with frontend. Step 3: After establishing connection, choose the required Data object to be displayed in the frontend. Step 4: Arrange the Data fields as desired and choose the required style. Step 5: Now Choose the report that has been loaded from report viewer. Step 6: Run the report page. OUTPUT:

Result: Thus reports were developed.

Menu design Exp.no:10 AIM: To design menu. Procedure: step 1: Drag and drop Site Map Data Source from Data, Menu from Navigation of toolbox. Step 2: Design the web page for addition. Step 3: Create a new page with sitemap extension and load it to the Site Map Data Source. Step 4: Add the address of additions web page in the url of sitemap.

protected void Button1_Click(object sender, EventArgs e) { int a, b,c; a = int.Parse(TextBox1.Text); b = int.Parse(TextBox2.Text); c = a + b; Label1.Text = c.ToString(); } protected void Button2_Click(object sender, EventArgs e) { int d, e,f; d = int.Parse(TextBox1.Text); e = int.Parse(TextBox2.Text); f = d - e; Label1.Text = f.ToString(); } protected void Button3_Click(object sender, EventArgs e) { int x, y,z; x = int.Parse(TextBox1.Text); y = int.Parse(TextBox2.Text); z = x * y; Label1.Text = z.ToString(); } protected void Button4_Click(object sender, EventArgs e) { int a1, b1,c1; a1 = int.Parse(TextBox1.Text); b1 = int.Parse(TextBox2.Text); c1 = a1 / b1; Label1.Text = c1.ToString(); }

Result: Thus menu was designed.

SIMPLE LOGIN PROJECT AIM:To design a login page using oracle as back-end and Microsoft visual studio as an front -end tool using c# language. PROJECT WORK DESCRIPTION:This project contain USERMODULE & ADMINMODULE .The user module has the status of the login details.It contains username,logindetails and user roll number. In admin module maintain the user module with username and password .The admin has all athe authorities to edit ,modify,delete the record's .This project is mainly used on maintain the user record with admin module. THE DESIGN OF THE BOTH INITIAL TABLE IS AS FOLLOWS:

Sql>select * from login; USERNAME PASSWORD ---------------------------------------------Saran Saran Sql> select * from admin; USERNAME PASSWORD ----------------------------------------------Admin Admin

Note:-(The values will be changing according to admin)

DESIGN VIEW OF LOGIN PAGE : Main page will be looked like as follows:

IF ERROR IN USERNAME /PASSWORD IT S DENOTED AS:

3.

User logged page :

4. ADMIN LOGGED ON PAGE:Before insertion:-

5.

After insertion username and password:-

6.

The values modified is reflected into table ,the table look like as follows

Sql>select * from login; USERNAME --------------------Saran Rajan

PASSWORD -------------------------Saran Rajan

7. After Setting username and password user can logged on using that username &password ,the table will be look like:-

8.

After deletion of a record:(rajan,rajan) table look likes:-

9. After deletion user cannot log in using that username and password: For example if its done it shows an error message as follows:

When login button is clicked it shows error window like this:

If cancel button is clicked it will exit the page

source code:using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.OleDb; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Session["name"] = txtUsername.Text.ToString(); } protected void btnlogin_Click(object sender, EventArgs e) { string constr; constr = "provider=MSDAORA;User Id=ananth;password=vvcoe;Data source=orcl"; OleDbConnection con = new OleDbConnection(constr); OleDbCommand cm = new OleDbCommand(); con.Open(); cm.Connection = con; cm.CommandText = "select * from login1"; OleDbDataReader read = cm.ExecuteReader(); if (read.Read()) { if (txtUsername.Text.Trim() == read[0].ToString() && txtPassword.Text.Trim() == read[1].ToString()) Response.Redirect("proj1.aspx");

else Response.Write("<script language=JavaScript>alert('Sorry,your username or password may be Invalid.Please enter Vaild Datas')</script>"); } con.Close(); } protected void txtUsername_TextChanged(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { if (txtUsername.Text == "admin" && txtPassword.Text == "admin") { Response.Redirect("http://localhost:49221/grid1/redir.aspx"); } else Response.Write("<script language=JavaScript>alert('Sorry,your username or password may be Invalid.Please enter Vaild Datas')</script>"); } }

Grid View
public partial class grid1 : System.Web.UI.Page { OleDbConnection con = new OleDbConnection("provider=MSDAORA;User Id=ananth;password=vvcoe;Data source=orcl;"); OleDbCommand cmd = new OleDbCommand(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindData(); } } private void BindData() { OleDbConnection con = new OleDbConnection("provider=MSDAORA;User Id=ananth;password=vvcoe;Data source=orcl;"); OleDbDataAdapter da = new OleDbDataAdapter("select * from emp1", con); DataTable dt = new DataTable(); da.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind(); } protected void Button1_Click(object sender, EventArgs e) { OleDbConnection con = new OleDbConnection("provider=MSDAORA;User Id=ananth;password=vvcoe;Data source=orcl;");

OleDbCommand cmd = new OleDbCommand(); DataTable t1; con.Open(); t1 = new DataTable(); DataSet ds = new DataSet(); OleDbDataAdapter da = new OleDbDataAdapter("select * from emp1", con); da.Fill(t1); DataRow dr = t1.NewRow(); t1.Rows.InsertAt(dr, 0); GridView1.EditIndex = 0; GridView1.DataSource = t1; GridView1.DataBind(); ((LinkButton)GridView1.Rows[0].Cells[0].Controls[0]).Text = "Insert"; da.Dispose(); con.Close(); } protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { GridView1.EditIndex = -1; BindData(); } protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { if (((LinkButton)GridView1.Rows[0].Cells[0].Controls[0]).Text == "Insert") { OleDbConnection con = new OleDbConnection("provider=MSDAORA;User Id=ananth;password=vvcoe;Data source=orcl;"); OleDbCommand cmd = new OleDbCommand(); cmd.Connection = con; cmd.CommandText = "INSERT INTO emp1 VALUES(?,?)"; cmd.Parameters.Add("no", OleDbType.Char).Value = ((TextBox)GridView1.Rows[0].Cells[1].Controls[0]).Text; cmd.Parameters.Add("name", OleDbType.Char).Value = ((TextBox)GridView1.Rows[0].Cells[2].Controls[0]).Text; con.Open(); cmd.ExecuteNonQuery(); con.Close(); } else { OleDbConnection con = new OleDbConnection("provider=MSDAORA;User Id=ananth;password=vvcoe;Data source=orcl;"); OleDbCommand cmd = new OleDbCommand(); cmd.Connection = con; cmd.CommandText = "UPDATE emp1 SET name=? WHERE no=?"; cmd.Parameters.Add("name", OleDbType.Char).Value = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text; cmd.Parameters.Add("no", OleDbType.Char).Value = ( GridView1.Rows[e.RowIndex].Cells[1].Text); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } GridView1.EditIndex = -1; BindData(); } protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { OleDbConnection con = new OleDbConnection("provider=MSDAORA;User Id=ananth;password=vvcoe;Data source=orcl;"); OleDbCommand cmd = new OleDbCommand();

cmd.Connection = con; cmd.CommandText = "DELETE from emp1 WHERE no=?";

cmd.Parameters.Add("no", OleDbType.Char).Value = (GridView1.Rows[e.RowIndex].Cells[1].Text); con.Open(); cmd.ExecuteNonQuery(); con.Close(); BindData(); } }

Result: Thus a project was developed.