0% found this document useful (0 votes)
148 views63 pages

Oracle &VB Record

The document appears to be records from a computer science department spanning 2018 to 2021. It includes details like the student's registration number, name, class, and subject. It documents the practical exams held with details of internal and external examiners. It also includes records of various programming assignments completed by the student with details of the program title, page number, and signature. The document aims to certify and maintain bonafide records of the work done by the student.

Uploaded by

prasath N
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
148 views63 pages

Oracle &VB Record

The document appears to be records from a computer science department spanning 2018 to 2021. It includes details like the student's registration number, name, class, and subject. It documents the practical exams held with details of internal and external examiners. It also includes records of various programming assignments completed by the student with details of the program title, page number, and signature. The document aims to certify and maintain bonafide records of the work done by the student.

Uploaded by

prasath N
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 63

DEPARTMENT OF COMPUTER SCIENCE

2018 – 2021

Register Number : _______________________________


Name : _______________________________
Class : _______________________________
Subject :________________________________
2018-2021

REG.NO:

Certified that this is bonafide record work done by _______________

___________________ __________________
Staff Incharge Head of the Department

Submitted for the Practical Examination held on ______________

________________ ___________________
Internal Examiner External Examiner
VISUAL BASIC

S.NO DATE TITLE PG.NO SIGNATURE

1 Number Conversion

2 List Box and Combo Box

3 Calculator

4 Common Dialog Box

5 Menu Driven Program

6 Student Database
EXNO: 1

DATE:

NUMBER CONVERSION

AIM:
To create a visual basic program to convert number into
A) Binary B) Octal C) Hexadecimal.

ALGORITHM:
STEP 1: Start the process.
STEP 2: Create the form with the following objects
LABEL: It is used to display text
TEXTBOX: It is used to get input
COMMAND BUTTON: Used for click

STEP 3: Add the properties and objects in proper on the form


STEP 4: Write the conversion coding for binary, octal, hexadecimal.
STEP 5: Run the program.
STEP 6: Stop the process.
NUMBER CONVERSION

Private Sub Command1_Click()


Dim value, remainder As Integer
Dim result As String
value = Val(Text1.Text)
Do
remainder = value Mod 2
If remainder = 0 Then
result = result + "0"
Else
result = result + "1"
End If
value = Int(value / 2)
Loop Until value = 0
Text2.Text = StrReverse(result)
value = Val(Text1.Text)
result = Oct(value)
Text3.Text = Str(result)
value = Val(Text1.Text)
result = Hex(value)
Text4.Text = result
End Sub
OUTPUT:

RESULT:

Thus the above program has been executed successfully and output has been
verified.
EX NO : 2

DATE:

LIST BOX AND COMBO BOX

AIM:
To write a simple visual basic program to add item to the list box with users input
and move the selected item to combo box one by one.

ALGORITHM:
STEP 1: Start the process.
STEP 2: Create the form with the following objects
LABEL: It is used to display text
TEXTBOX: It is used to get input
LISTBOX: It provides a collection of text item.
COMBO BOX: It combines the capacity of text box and list box
COMMAND BUTTON: It is used to change and move to list
and combo box

STEP 3: Add these objects in prepare place on the form


STEP 4: Write the code for move text to list box and move list to combo box
STEP 5: Run the program
STEP 6: Stop the process
LIST BOX AND COMBO BOX

Private Sub Form_Load()


List1.AddItem "SHAPNER"
End Sub
Private Sub List1_Click()
Select Case List1.ListIndex
Case 0
Combo1.AddItem (List1.Text)
Case 1
Combo1.AddItem (List1.Text)
Case 2
Combo1.AddItem (List1.Text)
End Select
End Sub
FORM DESIGN:
OUTPUT:

RESULT:

Thus the above program has been executed successfully and output has been
verified.
EXNO: 3

DATE: CALCULATOR

AIM:
Create a simple VB program to develop calculator with basic operations.

ALGORITHM:
STEP 1: Start the process
STEP 2: Design a form with text box to accept number array of command button
for number and operator.
STEP 3: If an operator „+‟ is clicked add text value to previously entered values.
STEP 4: If an operator „-‟ is clicked add text value to previously entered values.
STEP 5: If an operator „*‟ is clicked add text value to previously entered values.
STEP 6: If an operator „/‟ is clicked add text value to previously entered values.
STEP 7: Apply the same process for sin, cos, tan, sqrt, cube and pi and if it is
clicked the text value to previously entered values.
STEP 8: Display the result in a text box.
STEP 9: Stop the process.
CALCULATOR

Dim op, fn As Integer


Private Sub Command1_Click()
Text1.Text = Text1.Text & 1
End Sub

Private Sub Command10_Click()


Text1.Text = Text1.Text & 8
End Sub

Private Sub Command11_Click()


Text1.Text = Text1.Text & 9
End Sub
Private Sub Command12_Click()
op = 3
fn = Text1.Text
Text1.Text = " "
End Sub
Private Sub Command13_Click()
Text1.Text = Text1.Text & 0
End Sub
Private Sub Command14_Click()
Text1.Text = Text1.Text & (".")
End Sub

Private Sub Command15_Click()


If op = 1 Then
Text1.Text = Val(fn) + Val(Text1.Text)
ElseIf op = 2 Then
Text1.Text = Val(fn) - Val(Text1.Text)
ElseIf op = 3 Then
Text1.Text = Val(fn) * Val(Text1.Text)
ElseIf op = 4 Then
Text1.Text = Val(fn) / Val(Text1.Text)
End If
End Sub

Private Sub Command16_Click()


op = 4
fn = Text1.Text
Text1.Text = " "
End Sub
Private Sub Command17_Click()
Text1.Text = " "
End Sub

Private Sub Command18_Click()


End
End Sub

Private Sub Command2_Click()


Text1.Text = Text1.Text & 2
End Sub

Private Sub Command3_Click()


Text1.Text = Text1.Text & 3
End Sub

Private Sub Command4_Click()


op = 1
fn = Text1.Text
Text1.Text = " "
End Sub

Private Sub Command5_Click()


Text1.Text = Text1.Text & 4
End Sub

Private Sub Command6_Click()


Text1.Text = Text1.Text & 5
End Sub

Private Sub Command7_Click()


Text1.Text = Text1.Text & 6
End Sub

Private Sub Command8_Click()


op = 2
fn = Text1.Text
Text1.Text = " "
End Sub

Private Sub Command9_Click()


Text1.Text = Text1.Text & 7
End Sub
FORM DESIGN

OUTPUT:
RESULT:

Thus the above program has been executed successfully and output has been
verified.
EXNO: 4

DATE: COMMON DIALOGUE BOX

AIM:
To write a VB program using common dialog box to display the open. Save, font
dialog box without using the action control properties.

ALGORITHM:
STEP 1: Start the process.
STEP 2: Design the form with four command buttons and one image box.
STEP 3: Change the properties and captions for all buttons and image box.
STEP 4: Double click on the open command button and write the event procedure
for opening the file.
STEP 5: Double click on the save command button and on the event procedure for
saving the opened file.
STEP 6: Double click on the font command and write the event procedure for
changing the style of the label.
STEP 7: Write the event procedure for each menu items.
STEP 8: Stop the process.
COMMON DIALOGUE BOX

Private Sub Command1_Click ( )


Cd1.ShowOpen
End Sub

Private Sub Command2_Click ( )


Cd1.Flags = 1
Cd1.ShowFont
vtb1.Font = Cd1.FontName
End Sub

Private Sub Command3_Click ( )


Cd1.ShowPrinter
End Sub

Private Sub Command4_Click ( )


Cd1.ShowColor
End Sub

Private Sub Command5_Click ( )


Cd1.ShowSave
End Sub

Private Sub Command6_Click ( )


End
End Sub
FORM DESIGN:

OUTPUT:
RESULT:

Thus the above program has been executed successfully and output has been
verified.
EXNO: 5
DATE: MENU DRIVEN PROGRAM

AIM:
To write a VB program to develop a menu driven program and MDI form window
in the form and arrange them in the cascading, vertical, horizontal style using
menus.
ALGORITHM:
STEP 1: Start the process.
STEP 2: Create a MDI form and make other form in the project to be child of MDI.
STEP 3: Create a menu with form name available window style, color, if the form
name is selected then loads the specified form.
STEP 4: If the style is vertical, arrange the MDI child windows in vertical style.
STEP 5: If the style is horizontal, arrange the MDI child windows in horizontal
style.
STEP 6: If the style is cascading, arrange the MDI child windows in cascading
style.
STEP 7: If the color menu is selected to form, then apply the color as black color to
active form.
STEP 8: Stop the process.
MENU DRIVEN PROGRAM

Private Sub cscd_Click()


MDI. Arrange 0
End Sub

Private Sub frm1_Click()


Form1.Show
End Sub

Private Sub frm2_Click()


Form2.Show
End Sub

Private Sub frm3_Click()


Form3.Show
End Sub

Private Sub hrzntl_Click()


MDI.Arrange 1
End Sub

Private Sub MDIForm_Load()


Me.Height = 10000
Me.Width = 10000
Me.Left = 0
Me.Top = 0
End Sub

Private Sub vrtcl_Click()


MDI.Arrange 2
End Sub
FORM DESIGN:
OUTPUT:
RESULT:

Thus the above program has been executed successfully and output has been
verified.
EX.NO: 6

DATE:
STUDENT DATABASE

AIM:
To design a vb program to perform questionnaire using option.

ALGORITHM:

STEP 1: Start the process.


STEP 2: Design the form with 16 labels, 5 text boxes, 2 command button and 10
option button with 10 frames.
STEP 3: Change the properties and caption of the object in the frame.
STEP 4: In the event procedure of command 1 calculates the total, negative marks
and in the event procedure of command2 unload the form.
STEP 5: In the event procedure of the form load () mark all the value Property of
the option button to false.
STEP 6: In the event procedure of the option button click initialize the test box
value0.
STEP 7: Check whether the checked values are equal to the right answer if so all
“1” to correct answer else add ”1” to wrong answer.
STEP 8: Mark all other option button disable while the user select an option.
STEP 9: Stop the process.
STUDENT DATABASE

Public con As ADODB.Connection


Public rs As ADODB.Recordset
Private Sub Command1_Click()
rs.MovePrevious
If rs.BOF = True Then
MsgBox ("at the first data")
Else
Text1.Text = rs.Fields(0)
End If
End Sub

Private Sub Command2_Click()


rs.MoveNext
If rs.EOF = True Then
MsgBox ("end of table")
Else
Text1.Text = rs.Fields(0)
End If
End Sub

Private Sub Form_Load()


Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
con.Open "Provider=MSDAORA.1;User ID=system;password=system;Data
Source=localhost;Persist Security Info=False"
rs.Open "select* from studentdata1", con, adOpenDynamic
End Sub
ORACLE

S.NO DATE TITLE PG.NO SIGNATURE

1
Table Creation

2
Retrieving fields from
multiple tables

3
Table updation using PL\SQL

4
Splitting tables using cursors

5
Triggers

6
Exception handling
EX.NO .1

DATE :
TABLE CREATION

AIM:
To write an oracle program to create a table to Employee Details with the
necessary records and manipulate the Operators.

ALGORITHM:
STEP1: Start the process.
STEP2: Create a table EMP2 with a following fields empno, name, gender,
age , salary , designation and date of joining.
STEP3: Set the primary key constraint to the empno field.
STEP4: Describe the table using DESC EMP2 query.
STEP5: Insert ten records into EMP2 table.
STEP6: View the table using SELECT * FROM EMP2 query.
STEP7: Retrieve the fields from the EMP2 table using comparison, logical, set,
sorting and grouping operator.
STEP8: Stop the process.
CREATE A TABLE:

CREATE TABLE EMP2(EMPNO NUMBER(5) PRIMARY KEY,


NAME VARCHAR(20),
DESIGNATION VARCHAR2(10),
GENDER VARCHAR2(1),
AGE NUMBER(2),
DOJ DATE,
SALARY NUMBER(20));

Table created.

DESC EMP2;

Ta Data Len Preci Sc Primar Null Defa


ble Column Type gth sion ale y Key able ult
EM Numbe
EMPNO - 5 0 1 - -
P2 r
Varcha
NAME 20 - - - -
r2
DESIGN Varcha
10 - - - -
ATION r2
Varcha
GENDER 1 - - - -
r2
Numbe
AGE - 2 0 - -
r
DOJ Date 7 - - - -
Numbe
SALARY - 20 0 - -
r

INSERTING VALUES IN TABLE:

INSERT INTO EMP2 VALUES(111,'AFREEN','CEO','F',21,'13JUL17',30000);


INSERT INTO EMP2 VALUES(112,'AASHI','MANAGER','M',23,'14MAY17',37000);
INSERT INTO EMP2 VALUES(113,'MANJU','DESIGNER','F',20,'15JUN17',25000);
INSERT INTO EMP2 VALUES(114,'VARSHU','OFFICER','F',22,'19JUN17',35000);
INSERT INTO EMP2 VALUES(115,'ANU','ACCONTANT','F',24,'19MAR17',40000);
INSERT INTO EMP2 VALUES(116,'PRABA','ENGINEER','M',26,'21JUL17',31000);
INSERT INTO EMP2 VALUES(117,'NIVA','PROFFESSOR','F',23,'08JUL17',37000);
INSERT INTO EMP2 VALUES(118,'DHARANI','TRAINER','M',27,'18JUL17',40000);
INSERT INTO EMP2 VALUES(119,'KRISH','CASHIER','M',24,'21JUN17',46000);
INSERT INTO EMP2 VALUES(120,'SHANU','PROGRAMMER','F',25,'14JUL17',39000);

1 row(s) inserted

SELECT*FROM EMP2;

EMPNO NAME DESIGNATION GENDER AGE DOJ SALARY


111 AFREEN CEO F 21 13-JUL-17 30000
14-MAY-
112 AASHI MANAGER M 23 37000
17
15-JUN-
113 MANJU DESIGNER F 20 25000
17
19-JUN-
114 VARSHU OFFICER F 22 35000
17
19-MAR-
115 ANU ACCONTANT F 24 40000
17
116 PRABA ENGINEER M 26 21-JUL-17 31000
117 NIVA PROFFESSOR F 23 08-JUL-17 37000
118 DHARANI TRAINER M 27 18-JUL-17 40000
21-JUN-
119 KRISH CASHIER M 24 46000
17
120 SHANU PROGRAMMER F 25 14-JUL-17 39000

USING COMPARISION OPERATOR:

SELECT NAME FROM EMP2 WHERE SALARY>=25000

NAME
AFREEN
AASHI
MANJU
VARSHU
ANU
PRABA
NIVA
DHARANI
KRISH
SHANU
USING LOGICAL OPERATOR:

SELECT NAME,SALARY FROM EMP2 WHERE SALARY BETWEEN '10000' AND '34000';

NAME SALARY
AFREEN 30000
MANJU 25000
PRABA 31000

USING SET OPERATOR:

SELECT*FROM (SELECT EMPNO FROM EMP2 WHERE DESIGNATION='MANAGER')


UNION
(SELECT EMPNO FROM EMP2 WHERE DESIGNATION='CEO')

EMPNO
111
112

USING GROUP OPERATOR:

SELECT AGE,COUNT(*)FROM EMP2 GROUP BY AGE;

AGE COUNT(*)
22 1
25 1
21 1
20 1
26 1
24 2
23 2
27 1

USING SORTING OPERATOR:

SELECT EMPNO,NAME FROM EMP2 WHERE SALARY<=35000 ORDER BY GENDER;

EMPNO NAME
111 AFREEN
113 MANJU
114 VARSHU
116 PRABA
RESULT:

Thus the above program has been executed successfully and output has been
verified.
EX.NO .: 2

DATE :

RETRIEVING FIELDS FROM MULITIPLE TABLES

AIM:

To write a oracle program to create a master and transaction table for


library management system with the use of primary and foreign key and
create a report.

ALGORITHM:

STEP1: Start the process.


STEP2: Create a table MASTABLE with the following fields accno, title,
author and rate.
STEP3: Set primary key constraint to accno.
STEP4: Describe the table using dese MASTABLE query.
STEP5: Insert ten tables in MASTABLE.
STEP6: Create another table named TRANSTABLE with the following
fields accno , userid , sartid and startrd.
STEP7: Add foreign key constraint to accno field.
STEP8: Insert ten rows into TRANSTABLE table.
STEP9: Describe the table using DESC TRANSTABLE query.
STEP10: Using equijoint method retrieve accno , title , date of issue, and
return fields from MASTABLE and TRANSTABLE and
create a report.
STEP11: Stop the process.
CREATION OF MASTER TABLE:

CREATE TABLE MASTABLE


(
BookNo NUMBER(5) PRIMARY KEY,
Title VARCHAR2(20),
Author VARCHAR2(20),
Rate NUMBER(5)
);

Table created

DESC MASTABLE;

Table Column Data Lengt Precisi Scal Prima Nullab Defau Comme
Type h on e ry Key le lt nt
MASTAB BOOKN Numbe - 5 0 1 - - -
LE O r
TITLE Varcha 20 - - - - -
r2
AUTHO Varcha 20 - - - - -
R r2
RATE Numbe - 5 0 - - -
r
1-4

INSERTING VALUES IN TABLE:

INSERT INTO MASTABLE VALUES('111','ROMEO JULLIET','SHAKESPEARE','300')


INSERT INTO MASTABLE VALUES('112','SLEEPING BEAUTY','CHARLES
PERRAULT','700')
INSERT INTO MASTABLE VALUES('113','FROG PRINCE','BROTHERS GRIM','500')
INSERT INTO MASTABLE VALUES('114','MICE BANGLON','TILTON SPHERE','250')
INSERT INTO MASTABLE VALUES('115','SNOW WHITE','NARAYANAN','550')

1 row(s)inserted

VIEWING MASTER TABLE:


SELECT*FROM MASTABLE

BOOKNO TITLE AUTHOR RATE

111 ROMEO JULLIET SHAKESPEARE 300


112 SLEEPING BEAUTY CHARLES PERRAULT 700
113 FROG PRINCE BROTHERS GRIM 500
114 MICE BANGLON TILTON SPHERE 250
115 SNOW WHITE NARAYANAN 550

CREATION OF TRANSACTION TABLE:

CREATE TABLE TRANSTABLE


(
BookNo NUMBER(5),
USERId VARCHAR2(10),
ISSUEDATE DATE,
RETURNDATE DATE,
FOREIGN KEY(BookNo)
REFERENCES MASTABLE(BookNo));

Table created.

DESC TRANSTABLE;

Table Column Data Length Precision Scale Primary Nullable Default


Type Key
TRANSTABLE
BOOKNO Number - 5 0 - -
USERID Varchar2 10 - - - -
ISSUEDATE Date 7 - - - -
RETURNDATE Date 7 - - -

INSERTING RECORDS:

INSERT INTO TRANSTABLE VALUES('111','AAOO1','07JUN17','18JUL17');


INSERT INTO TRANSTABLE VALUES(„112‟,‟AA561‟,‟27JUL17‟,‟05AUG17‟);
INSERT INTO TRANSTABLE VALUES('113','AB7891','21MAR17','09APR17');
INSERT INTO TRANSTABLE VALUES('114','AN091','12APR17','29APR17');
INSERT INTO TRANSTABLE VALUES('115','AT401','25MAY17','12JUN17');
1 row(s)inserted

VIEWING TRANSCATION TABLE:

SELECT*FROM TRANSTABLE;
BOOKNO USERID ISSUEDATE RETURNDATE
111 AAOO1 07-JUN-17 18-JUL-17
112 AA561 27-JUL-17 05-AUG-17
113 AB7891 21-MAR-17 09-APR-17
114 AN091 12-APR-17 29-APR-17
115 AT401 25-MAY-17 12-JUN-17

VIEWING FIELDS FROM TWO TABLES:

SELECT
TRANSTABLE.BookNo,TRANSTABLE.ISSUEDATE,TRANSTABLE.RETURNDATE,MAST
ABLE.TITLE FROM TRANSTABLE,MASTABLE WHERE
TRANSTABLE.BookNo=MASTABLE.BookNo;

BOOKNO ISSUE DATE RETURNDATE TITLE


111 07-JUN-17 18-JUL-17 ROMEO JULLIET
112 27-JUL-17 05-AUG-17 SLEEPING BEAUTY
113 21-MAR-17 09-APR-17 FROG PRINCE
114 12-APR-17 29-APR-17 MICE BANGLON
115 25-MAY-17 12-JUN-17 SNOW WHITE

RESULT:

Thus the above program has been executed successfully and output has been
verified.
EX.NO : 3

DATE:

TABLE UPDATION USING PL/SQL

AIM:
To write a oracle program to update the table using PL/SQL.

ALGORITHM:
STEP 1: Start the process.
STEP 2: Create the table named inventory with the following fields prono, proname
and rate.
STEP 3: Insert few records into the table.
STEP 4: Update the rate field by 20% using update query.
STEP 5: Alter the table by adding new field using alter query.
STEP 6: View the table using select query to check whether new column is
updated.
STEP 7: Stop the process.
CREATE A TABLE:

CREATE TABLE INVENTORY3


(
PRODUCTNUM NUMBER(5),
PRODUCTNAME VARCHAR(10),
RATE NUMBER(5)
);

Table created.

DESC INVENTORY3

Data Len Precis Sca Primary Nulla


Table Column Type gth ion le Key ble
INVENT PRODUCT
Number - 5 0 -
ORY3 NUM
PRODUCT Varchar
10 - - -
NAME 2
RATE Number - 5 0 -

INSERTING VALUES INTO TABLE:

INSERT INTO INVENTORY3 VALUES('1021','FACE CREAM','650');


INSERT INTO INVENTORY3 VALUES('1246','FACE PACK','950');
INSERT INTO INVENTORY3 VALUES('1356','KAJAL','450');
INSERT INTO INVENTORY3 VALUES('1006','LIPSTICK','799');
INSERT INTO INVENTORY3 VALUES('1022','PERFUME','519');
INSERT INTO INVENTORY3 VALUES('1862','SHAMPOO','299');
INSERT INTO INVENTORY3 VALUES('3262','POWDER','250');
INSERT INTO INVENTORY3 VALUES('4510','MASKARA','650');
INSERT INTO INVENTORY3 VALUES('1245','LIP GLOSS','800');
INSERT INTO INVENTORY3 VALUES('3545','NAILPOLISH','500');

1 row(s) inserted.

VIEWING THE TABLE:

SELECT * FROM INVENTORY3


PRODUCTNUM PRODUCTNAME RATE
1021 FACE CREAM 650
1246 FACE PACK 950
1356 KAJAL 450
1006 LIPSTICK 799
1022 PERFUME 519
1862 SHAMPOO 299
3262 POWDER 250
4510 MASKARA 650
1245 LIP GLOSS 800
3545 NAILPOLISH 500

UPDATING A TABLE:

DECLARE
RATE NUMBER(5);
BEGIN
UPDATE INVENTORY3 SET RATE=RATE+RATE*20/100;
COMMIT;
END;

Statement processed.

PRODUCTNUM PRODUCTNAME RATE


1021 FACE CREAM 780
1246 FACE PACK 1140
1356 KAJAL 540
1006 LIPSTICK 959
1022 PERFUME 623
1862 SHAMPOO 359
3262 POWDER 300
4510 MASKARA 780
1245 LIP GLOSS 960
3545 NAILPOLISH 600

ALTERING A TABLE:

ALTER TABLE INVENTORY3


ADD NUMOFITEM NUMBER(5);
Table altered.
DESC INVENTORY3

Data Len Precis Sca Primary Nulla


Table Column Type gth ion le Key ble
INVENT PRODUCT
Number - 5 0 -
ORY3 NUM
PRODUCT Varchar
10 - - -
NAME 2
RATE Number - 5 0 -
NUMOFIT
Number - 5 0 -
EM

VIEWING A TABLE AFTER ALTERING:


SELECT* FROM INVENTORY3;

PRODUCTNUM PRODUCTNAME RATE NUMOFITEM


1021 FACE CREAM 780 -
1246 FACE PACK 1140 -
1356 KAJAL 540 -
1006 LIPSTICK 959 -
1022 PERFUME 623 -
1862 SHAMPOO 359 -
3262 POWDER 300 -
4510 MASKARA 780 -
1245 LIP GLOSS 960 -
3545 NAILPOLISH 600 -

RESULT
Thus the above program has been executed successfully and output has been
verified.
EX.NO. : 4

DATE :
SPLITTING TABLE USING CURSOR

AIM:
To write a oracle program to split the table into two tables and handle the
records using cursors.

ALGORITHM:

STEP 1: Start the process.


STEP 2: Create a table named STUDENT SPLIT with following fields
regno, name,degree, mark1, mark2, mark3, total and result.
STEP 3: Create a record called rec.
STEP 4: And check the result whether pass or fail.
STEP 5: Using the for loop print all the record.
STEP 6: If result “fail” execute the for loop for “fail”.
STEP 7: If result “pass” execute the loop for “pass” with regno, name,
total and result.
STEP 8: Stop the process.
CREATING A TABLE:

CREATE TABLE STUDENTSPLIT


(
REGNO NUMBER(5) CONSTRAINT STUDENTSPLIT_REGNO_PK PRIMARY KEY,
NAME VARCHAR2(20),
DEGREE VARCHAR2(10),
MARK1 NUMBER(3),
MARK2 NUMBER(3),
MARK3 NUMBER(3),
TOTAL NUMBER(3),
RESULT VARCHAR2(6)
);

Table Created

DESC STUDENTSPLIT

INSERTING ROWS:
INSERT INTO STUDENTSPLIT VALUES('1421','ASHMI','BCA',80,72,95,247,'PASS');
INSERT INTO STUDENTSPLIT VALUES('1422','BANU','BCA',85,22,65,172,'FAIL');

INSERT INTO STUDENTSPLIT VALUES('1423','HARITHA','BCA',95,52,35,182,'PASS');


INSERT INTO STUDENTSPLIT VALUES('1424','ILAKIYA','BCA',75,52,34,161,'FAIL');
INSERT INTO STUDENTSPLIT VALUES('1425','JANAKI','BCA',25,52,35,112,'FAIL');
INSERT INTO STUDENTSPLIT VALUES('1426','KAVIYA','BCA',95,52,40,187,'PASS');
INSERT INTO STUDENTSPLIT VALUES('1427','HARITHA','BCA',95,50,41,186,'PASS');

Rows inserted.
VIEWING TABLE:
SELECT *FROM STUDENTSPLIT

SPLITING THE TABLES:

DECLARE
CURSOR CUR_STUDET IS SELECT *FROM STUDENTSPLIT
WHERE RESULT = 'PASS' OR RESULT ='FAIL';
STUDET_REC CUR_STUDET%ROWTYPE;
BEGIN
DBMS_OUTPUT.PUT_LINE('FAIL MARK');
FOR STUDET_REC IN CUR_STUDET LOOP
IF STUDET_REC.RESULT='FAIL' THEN
DBMS_OUTPUT.PUT_LINE(STUDET_REC.REGNO || ' ' || STUDET_REC.NAME || '
'||STUDET_REC.DEGREE|| ' '||STUDET_REC.TOTAL||' '||STUDET_REC.RESULT );
END IF;
END LOOP;
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('PASS MARK');
FOR STUDET_REC IN CUR_STUDET LOOP
IF STUDET_REC.RESULT='PASS' THEN
DBMS_OUTPUT.PUT_LINE(STUDET_REC.REGNO || ' ' || STUDET_REC.NAME || '
'||STUDET_REC.DEGREE|| ' '||STUDET_REC.TOTAL||' '||STUDET_REC.RESULT );
END IF;
END LOOP;
END;
RESULT:

Thus the above program has been executed successfully and output has been
verified.
EX.NO .:5

DATE :
TRIGGER

AIM:
To write a oracle program to create a database trigger to implement on master
and transaction table.

ALGORITHM:

STEP 1: Start the process.


STEP 2: Create a table master1 with the following fields provide
proname, cusid, cusname, price and qty.
STEP 3: Insert record into master1 table.
STEP 4: Create a table called trans2 with the following fields
provide proid, supno, supname, loc and qtypurchase.
STEP 5: Insert record into trans2 table.
STEP 6: Create a trigger for master1 and trans2 table.
STEP 7: If price is greater than 100 in master1 then trigger is
raised else record is inserted.
STEP 8: Supno is greater than 1000 in trans2 table trigger is
raised else record is inserted.
STEP 9: Stop the process.
CREATING A MASTER TABLE:

CREATE TABLE MASTER1


(
PROID NUMBER(5) CONSTRAINT MASTER1_PROID_PK PRIMARY KEY,
PRONAME VARCHAR2(25),
CUSID NUMBER(5),
CUSNAME VARCHAR2(15),
PRICE NUMBER(5),
QTY NUMBER(5)
);

Table Created

DESC MASTER1

INSERTING RECORDS INTO MASTER TABLE:


INSERT INTO MASTER1 VALUES('1091','PONDS WHITE
BEAUTY','121','ASHMI','65','260');

INSERT INTO MASTER1 VALUES('1092','HIMALAYA WASH','122','SAPTHIKA','65','401');

INSERT INTO MASTER1 VALUES('1093','EYECONIC','123','HARSHA','55','87');

INSERT INTO MASTER1 VALUES('1094','MASCARA','124','ANU','110','80');

INSERT INTO MASTER1 VALUES('1095','LIPSTICK','125','THIYA','99','156');

Rows inserted
VIEWING MASTER TABLE:

SELECT*FROM MASTER1

CREATING TRANSACTION TABLE:


CREATE TABLE TRANS2
(
PROID NUMBER(5),
SUPNO NUMBER(5),
SUPNAME VARCHAR2(15),
LOC VARCHAR2(15),
QTYPURCHASE NUMBER(5),
CONSTRAINT FK_MASTER1
FOREIGN KEY (PROID)
REFERENCES MASTER1(PROID)
);
DESC TRANS2

INSERTING RECORDS INTO TRANSACTION TABLE:


INSERT INTO TRANS2 VALUES('1091','456','KARTHIC','CBE','80');

INSERT INTO TRANS2 VALUES('1092','457','SHIVA','CHENNAI','45');

INSERT INTO TRANS2 VALUES('1093','458','LATHIKA','BANGLORE','65');

INSERT INTO TRANS2 VALUES('1094','459','SUNITHA','PUNE','39');

INSERT INTO TRANS2 VALUES('1095','460','AKILAN','MUMBAI','65');

Rows inserted

VIEWING TRANSACTION TABLE:


SELECT*FROM TRANS2
TRIGGER CREATION FOR MASTER TABLE :
CREATE TRIGGER TRIG2
BEFORE INSERT
ON MASTER1
FOR EACH ROW
BEGIN
IF (:NEW.PRICE > 100) THEN
RAISE_APPLICATION_ERROR(-20000, 'TRIGGER RAISED');
END IF;
END;

Trigger Created

INSERT INTO MASTER1 VALUES ('1097','EYELINER','127','HALENA','155','189');

INSERT INTO MASTER1 VALUES ('1097','EYE LINER','127','HALENA','80','189');

MASTER TABLE AFTER TRIGGER RAISED:


SELECT *FROM MASTER1;

TRIGGER CREATION FOR TRANSACTION TABLE :


CREATE TRIGGER TRIG14
BEFORE INSERT
ON TRANS2
FOR EACH ROW
BEGIN
IF (:NEW.SUPNO > 1000) THEN
RAISE_APPLICATION_ERROR(-20000, 'TRIGGER RAISED');
END IF;
END;

Trigger Created

INSERT INTO TRANS2 VALUES ('1096','1853','DHASTHAKEER','NAGPUR','99');

INSERT INTO TRANS2 VALUES ('1097','853','DHASTHAKEER','NAGPUR','99');

TRANSCATION TABLE AFTER TRIGGER RAISED:


SELECT *FROM TRANS2;

RESULT

Thus the above program has been executed successfully and output has been
verified.
EX.NO .:6

DATE :
EXCEPTION HANDLING
AIM:
To write a oracle program to raise exception in bank account management table
on deposit amount is zero.

ALGORITHM:

STEP 1: Start the process.


STEP 2: Create a table bank3 with following fields accno, name, address,
phoneno, bankname and deposit.
STEP 3: Insert the rows into the table bank3.
STEP 4: Declare the variable depo of deposit % type and check the
condition using query.
STEP 5: Using if condition check whether the deposit value is equal or 0
or null else print the value.
STEP 6: Stop the process.
CREATING A TABLE:

CREATE TABLE BANK3


(
ACCNO NUMBER(5),
NAME VARCHAR2(10),
ADDRESS VARCHAR2(20),
PHONENO NUMBER(10),
BANKNAME VARCHAR2(15),
BALANCE NUMBER(5),
DEPOSIT NUMBER(7)
);

Table Created

DESC BANK3

INSERTING ROWS:
INSERT INTO BANK3 VALUES(1021,'ASHMI','8/86 KANGAYAM-
TRI','9876543210','CANARA','50000','60000');
INSERT INTO BANK3 VALUES(1022,'HARSHA','12/22 RANTHAPURI-
CBE','9789712357','SBI','65000','0');
INSERT INTO BANK3 VALUES(1023,'KAIYA','1/22 KARAMATAI-
CBE','8508707239','INDIAN BANK','9000','1000');
INSERT INTO BANK3 VALUES(1024,'KARTHIC','11/122 SRM STR-
TRI','9786543210','SBI','59000','6000');
INSERT INTO BANK3 VALUES(1025,'SHIVA','7/16 KOTHAGRI-
OOTY','8508995230','TRAVANCORE','70000','');
INSERT INTO BANK3 VALUES(1026,'REVATHI','98/16 IRUGUR-
CBE','9875643210','CANARA','25000','0');
INSERT INTO BANK3 VALUES(1027,'ISHANAN','97/8 RSV STR-
SULUR','8508995230','INDIAN BANK','7000','3000');

VIEWING TABLE:
SELECT*FROM BANK3

DECLARE
INVALID_DEPOSIT EXCEPTION;
NO_DEPOSIT EXCEPTION;
V_DEPO BANK3.DEPOSIT%TYPE;
BEGIN
SELECT DEPOSIT INTO V_DEPO FROM BANK3 WHERE ACCNO=1025;
IF V_DEPO=0 THEN
RAISE INVALID_DEPOSIT;
ELSIF V_DEPO IS NULL THEN
RAISE NO_DEPOSIT;
ELSE
DBMS_OUTPUT.PUT_LINE(TO_CHAR(V_DEPO));
END IF;
EXCEPTION
WHEN INVALID_DEPOSIT THEN
DBMS_OUTPUT.PUT_LINE('DEPOSIT EQUAL TO 0');
WHEN NO_DEPOSIT THEN
DBMS_OUTPUT.PUT_LINE('NO DEPOSIT AMOUNT');
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(TO_CHAR(V_DEPO));
END;

11000

Statement Processed

SELECT DEPOSIT INTO V_DEPO FROM BANK3 WHERE ACCNO=1022;

DEPOSIT EQUAL TO 0

Statement Processed

SELECT DEPOSIT INTO V_DEPO FROM BANK3 WHERE ACCNO=1025;


NO DEPOSIT AMOUNT

Statement Processed

RESULT:

Thus the above program has been executed successfully and output has been
verified.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy