0% found this document useful (0 votes)
26 views47 pages

VB Ora Full

Uploaded by

kathirkanth74
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)
26 views47 pages

VB Ora Full

Uploaded by

kathirkanth74
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/ 47

Visual

basic

1.CALCULATOR
Dim preval As Double
Dim curval As Double
Dim result As Double
Dim choice As String

Private Sub Command1_Click(Index As Integer)


Text1.Text = Text1.Text & Command(Index).Caption
curval = Val(Text1.Text)
End Sub

Private Sub Commanddiv_Click()


Text1.Text = “ “
preval = curval
curval = 0
choice = “/”
End Sub

Private Sub Commandend_Click()


End
End Sub

Private Sub Commandmin_Click()


Text1.Text = “ “
preval = curval
curval = 0
choice = “-”
End Sub

Private Sub Commandplus_Click()


Text1.Text = “ “
preval = curval
curval = 0
choice = “+”
End Sub

Private Sub Commandac_Click()


preval = curval
curval = 0
Text1.Text = “ 0 “
End Sub

Private Sub Commandequ_Click()


Select Case choice
Case “+”
result = preval + curval
Text1. Text = Str ( result )
Case “-”
result = preval - curval
Text1. Text = Str ( result )
Case “*”
result = preval * curval
Text1. Text = Str ( result )
Case “/”
result = preval / curval
Text1. Text = Str ( result )
End Sub
Private Sub Commandmul_Click()
Text1.Text = “ “
preval = curval
curval = 0
choice = “*”
End Sub

Private Sub Commandneg_Click()


curval = -curval
Text1.Text = Str( curval)
End Sub

Private Sub CommandClear_Click()


Text1.Text = “ “
End Sub

Private Sub CommandExit_Click()


End
End Sub

OUTPUT
2.a.GENERATE FIBONACCI SERIES

Dim a As Integer

Dim b As Integer
Dim fib As Integer
Private Sub Command1_Click()
a=0
b=1
Dim userinput, i As Integer
userinput = Val(Text1.Text)
i = userinput
List1.AddItem (1)
Do
fib = a + b
a=b
b = fib
List1.AddItem (fib)
i=i+1
Loop While fib < i
End Sub
Private Sub Command2_Click()
Text1.Text = ""
List1.Clear
Text1.SetFocus
End Sub
Private Sub Command3_Click()
End End Sub
OUTPUT
b.FIND THE SUM OF N NUMBERS

Dim a As Integer
Dim s As Integer
Dim n As Integer
Private Sub Command1_Click()
a=1
s=0
n = Val(Text1.Text)
Do While a <= n
s=s+a
a=a+1
Loop
Text2.Text = Str(s)
End Sub

Private Sub Command2_Click()


Text1.Text = ""
Text2.Text = ""
End Sub
OUTPUT
3.MENU DRIVEN

Private Sub Blue_Click()


Form1.BackColor = vbBlue
Form2.BackColor = vbBlue
Form3.BackColor = vbBlue
End Sub

Private Sub Cascade_Click()


Form1.Show
Form2.Show
Form3.Show
MDIForm1.Arrange (vbCascade)
End Sub

Private Sub Exit_Click()


End
End Sub

Private Sub Green_Click()


Form1.BackColor = vbGreen
Form2.BackColor = vbGreen
Form3.BackColor = vbGreen
End Sub

Private Sub Horizontal_Click()


Form1.Show
Form2.Show
Form3.Show
MDIForm1.Arrange (vbHorizontal)
End Sub

Private Sub MDIForm_Load()


Me.WindowState = 2
End Sub

Private Sub Red_Click()


Form1.BackColor = vbRed
Form2.BackColor = vbRed
Form3.BackColor = vbRed
End Sub

Private Sub Vertical_Click()


Form1.Show
Form2.Show
Form3.Show
MDIForm1.Arrange (vbVertical)
End Sub
OUTPUT
4.DRIVE LIST BOX,DIRLIST BOX & FILE LIST BOX
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()


Dir1.Path = Drive1.Drive
End Sub

Private Sub new_Click()


RichTextBox1 = " "
End Sub

Private Sub open_Click()


CommonDialog1.ShowOpen
RichTextBox1.LoadFile (CommonDialog1.FileName)
End Sub

Private Sub save_Click()


CommonDialog1.ShowSave
RichTextBox1.SaveFile (CommonDialog1.FileName)
End Sub
OUTPUT
5.COMMON DIALOG CONTROL

Private Sub Color_Click()


CommonDialog1.ShowColor
RichTextBox1.SelColor = CommonDialog1.color
End Sub

Private Sub Exit_Click()


End
End Sub

Private Sub New_Click()


RichTextBox1 = “ “
End Sub

Private Sub Open_Click()


CommonDialog1.ShowOpen
RichTextBox1.LoadFile (CommonDialog1.FileName)
End Sub

Private Sub Save_Click()


CommonDialog1.ShowSave
RichTextBox1.SaveFile (CommonDialog1.FileName)
End Sub
Private Sub Ten_Click()
RichTextBox1.SelFontSize = 10
End Sub

Private Sub Twenty_Click()


RichTextBox1.SelFontSize = 20
End Sub

Private Sub Thirty_Click()


RichTextBox1.SelFontSize = 30
End Sub
OUTPUT
6.ANIMATION

Private Sub Timer1_Timer()


If Image1.Visible = True Then
Image1.Visible = False
Image2.Visible = True
ElseIf Image2.Visible = True Then
Image2.Visible = False
Image1.Visible = True
End If
End Sub
OUTPUT
7. NUMBER CONVERSION

Dim deci, bin, oct, hexa As Integer


Dim hex As String

Private Sub Command1_Click()


deci = Val(Text1.Text)
Do While (deci <> 0)
bin = deci Mod 2
deci = deci \ 2
Text2.Text = bin & Text2.Text
Loop
End Sub

Private Sub Command2_Click()


Text2.Text = " "
Deci = Val(Text1.Text)
If (deci <= 7) Then
Text2.Text = Text1.Text
Else
Do While (deci <> 0)
oct = deci Mod 8
deci = deci \ 8
Text2.Text = oct & Text2.Text
Loop
End If
End Sub
Private Sub Command3_Click()
Text2.Text = " "
deci = Val(Text1.Text)
If (deci > 0 And deci <= 9) Then
Text2.Text = Text1.Text
Else
Do While (deci <> 0)
hexa = deci Mod 16
If (hexa =10) Then
hex = “A”
ElseIf (hexa =11) Then
hex = “B”
ElseIf (hexa =12) Then
hex = “C”
ElseIf (hexa =13) Then
hex = “D”
ElseIf (hexa =14) Then
hex = “E”
ElseIf (hexa =15) Then
hex = “F”
End If
Deci = deci \ 16
If (hexa < 9) Then
Text2.Text = hexa & Text2.Text
End If
Loop
End If
End Sub

Private Sub Command4_Click()


Text1.Text = " "
Text2.Text = " "
End Sub

Private Sub Command5_Click()


End
End Sub
OUTPUT
Oracle
1. DATA MANIPULATION

SQL> create table employee(eno number(20) constraint employee_eno_pk primary


key,name varchar2(20),des varchar2(20),gender char,age number(3),doj date,salary
number(10));
Table created.

SQL> desc employee;


Name Null? Type
-------------------- -------- ----------------------------
NO NOT NULL NUMBER(20)
NAME VARCHAR2(20)
DES VARCHAR2(20)
GENDER CHAR(1)
AGE NUMBER(3)
DOJ DATE
SALARY NUMBER(10)

SQL> insert into employee


values('&no','&name','&des','&gender','&age','&doj','&salary');
Enter value for no: 1
Enter value for name: Alfiya
Enter value for des: Lecturer
Enter value for gender: F
Enter value for age: 19
Enter value for doj: 30-jun-2015
Enter value for salary: 25000
old 1: insert into employee values('&no','&name','&des','&gender','&age','&doj','&salary')
new 1: insert into employee values(‘1’,’Alfiya’,’Lecturer’,’F’,’19’,’30-jun-2015’,’25000’)
1 row created.

SQL> /
Enter value for no: 2
Enter value for name: Selin
Enter value for des: Officer
Enter value for gender: F
Enter value for age: 20
Enter value for doj: 04-may-2014
Enter value for salary: 30000
old 1: insert into employee values('&no','&name','&des','&gender','&age','&doj','&salary')
new 1: insert into employee values(‘2’,’Selin’,’Officer’,’F’,’20’,’04-may-2014’,’30000’)
1 row created.

SQL> /
Enter value for no: 3
Enter value for name: Kalai
Enter value for des: Manager
Enter value for gender: F
Enter value for age: 21
Enter value for doj: 06-jun-2012
Enter value for salary: 20000
old 1: insert into employee values('&no','&name','&des','&gender','&age','&doj','&salary')
new 1: insert into employee values(‘3’,’Kalai’,’Manager’,’F’,’21’,’06-jun-2012’,’20000’)
1 row created.

SQL> /
Enter value for no: 4
Enter value for name: Akil
Enter value for des: Manager
Enter value for gender: M
Enter value for age: 25
Enter value for doj: 23-feb-2000
Enter value for salary: 10000
old 1: insert into employee values('&no','&name','&des','&gender','&age','&doj','&salary')
new 1: insert into employee values(‘4’,’Akil’,’Manager’,’M’,’25’,’23-feb-2000’,’10000’)
1 row created.
SQL> /
Enter value for no: 5
Enter value for name: Naveen
Enter value for des: Lecturer
Enter value for gender: M
Enter value for age: 27
Enter value for doj: 27-nov-2016
Enter value for salary: 15000
old 1: insert into employee values('&no','&name','&des','&gender','&age','&doj','&salary')
new 1: insert into employee values(‘5’,’Naveen’,’Lecturer’,’M’,’27’,’27-nov-
2016’,’15000’)
1 row created.

SQL> /
Enter value for no: 6
Enter value for name: Karthi
Enter value for des:Faculty
Enter value for gender: M
Enter value for age: 35
Enter value for doj: 06-july-1998
Enter value for salary: 350000
old 1: insert into employee values('&no','&name','&des','&gender','&age','&doj','&salary')
new 1: insert into employee values(‘6’,’Karthi’,’Faculty’,’M’,’35’,’06-july-1998’,’350000’)
1 row created.

SQL> /
Enter value for no: 7
Enter value for name: Sathya
Enter value for des: Lecturer
Enter value for gender: F
Enter value for age: 24
Enter value for doj: 22-aug-2017
Enter value for salary: 16000
old 1: insert into employee values('&no','&name','&des','&gender','&age','&doj','&salary')
new 1: insert into employee values(‘7’,’Sathya’,’Lecturer’,’F’,’24’,’22-aug-2017’,’16000’)
1 row created.

SQL> /
Enter value for no: 8
Enter value for name: Hema
Enter value for des: Manager
Enter value for gender: F
Enter value for age: 35
Enter value for doj: 24-sep-2001
Enter value for salary: 20000
old 1: insert into employee values('&no','&name','&des','&gender','&age','&doj','&salary')
new 1: insert into employee values(‘8’,’Hema’,’Manager’,’F’,’35’,’24-sep-2001’,’20000’)
1 row created.

SQL> /
Enter value for no: 9
Enter value for name: Ashik
Enter value for des: Project Manager
Enter value for gender: M
Enter value for age: 26
Enter value for doj: 27-feb-2013
Enter value for salary:18000
old 1: insert into employee values('&no','&name','&des','&gender','&age','&doj','&salary')
new 1: insert into employee values(‘9’,’Ashik’,’Project Manager’,’M’,’26’,’27-feb-
2013’,’18000’)
1 row created.

SQL> /
Enter value for no: 10
Enter value for name: Kavin
Enter value for des: Guide
Enter value for gender: M
Enter value for age: 19
Enter value for doj: 18-jun-2011
Enter value for salary:15000
old 1: insert into employee values('&no','&name','&des','&gender','&age','&doj','&salary')
new 1: insert into employee values(‘10’,’Kavin’,’Guide’,’M’,’19’,’18-jun-2011’,’15000’)
1 row created.

SQL> select * from employee;

ENO NAME DES G AGE DOJ SALARY


----- ------------------ -------------------- -- -------- ------------ -------------
1 Alfiya Lecturer F 19 30-JUN-15 25000
2 Selin Officer F 20 04-MAY-14 30000
3 Kalai Manager F 21 06-JUN-12 20000
ENO NAME DES G AGE DOJ SALARY
----- ------------------ -------------------- -- -------- ------------ -------------
4 Akil Manager M 25 23-FEB-00 10000
5 Naveen Lecturer M 27 27-NOV-16 15000
6 Karthi Faculty M 35 06-JUL-98 350000
ENO NAME DES G AGE DOJ SALARY
----- ------------------ -------------------- -- -------- ------------ -------------
7 Sathya Lecturer F 24 22-AUG-17 16000
8 Hema Manager F 35 24-SEP-01 20000
9 Ashik Project M 26 27-FEB-13 18000
Manager
ENO NAME DES G AGE DOJ SALARY
----- ------------------ -------------------- -- -------- ------------ -------------
10 Kavin Guide M 19 18-JUN-11 15000
10 rows selected.

SQL> select * from employee where gender in('f');


ENO NAME DES G AGE DOJ SALARY
------ -------------------- -------------------- -- ---------- ----------- -------------
1 Alfiya Lecturer F 19 30-JUN-15 25000
2 Selin Officer F 20 04-MAY-14 30000
3 Kalai Manager F 21 06-JUN-12 20000
ENO NAME DES G AGE DOJ SALARY
------ -------------------- -------------------- -- ---------- ----------- -------------
7 Sathya Lecturer F 24 22-AUG-17 16000
8 Hema Manager F 35 24-SEP-01 20000

SQL> select * from employee where des like ('L%');


ENO NAME DES G AGE DOJ SALARY
----- ------------------ -------------------- -- --------- ----------- --------------
1 Alfiya Lecturer F 19 30-JUN-15 25000
5 Naveen Lecturer M 27 27-NOV-16 15000
7 Sathya Lecturer F 24 22-AUG-17 16000

SQL> select * from employee where age between 25 and 36;


ENO NAME DES G AGE DOJ SALARY
------ ----------------- ----------- -- ------- --------- ----------------
4 Akil Manager M 25 23-FEB-00 10000
5 Naveen Lecturer M 27 27-NOV-16 15000
6 Karthi Faculty M 35 06-JUL-98 350000
ENO NAME DES G AGE DOJ SALARY
------ ----------------- ----------- -- ------- --------- ----------------
8 Hema Manager F 35 24-SEP-01 20000
9 Ashik Project M 26 27-FEB-13 18000
Manager

SQL> select * from employee where age=25 or age=36;


ENO NAME DES G AGE DOJ SALARY
----- -------------- -------------- --- ----------- ---------- ---------------
4 Akil Manager M 25 23-FEB-00 10000

SQL> select * from employee where not des='lecturer';


ENO NAME DES G AGE DOJ SALARY
----- ----------------- ------------- -- ------------ ------- ---------------
2 Selin Officer F 20 04-MAY-14 30000
3 Kalai Manager F 21 06-JUN-12 20000
4 Akil Manager M 25 23-FEB-00 10000
ENO NAME DES G AGE DOJ SALARY
----- -------------- -------------- --- ----------- ---------- ---------------
6 Karthi Faculty M 35 06-JUL-98 350000
8 Hema Manager F 35 24-SEP-01 20000
9 Ashik Project M 26 27-FEB-13 18000
Manager
ENO NAME DES G AGE DOJ SALARY
----- -------------- -------------- --- ----------- ---------- ---------------
10 Kavin Guide M 19 18-JUN-11 15000
7 rows selected.

SQL> select * from employee order by name;


ENO NAME DES G AGE DOJ SALARY
------ ----------------- ---------- ---- -------- -------- ----------------
4 Akil Manager M 25 23-FEB-00 10000
1 Alfiya Lecturer F 19 30-JUN-15 25000
9 Ashik Project M 26 27-FEB-13 18000
Manager
ENO NAME DES G AGE DOJ SALARY
------ ----------------- ---------- ---- -------- -------- ----------------
8 Hema Manager F 35 24-SEP-01 20000
3 Kalai Manager F 21 06-JUN-12 20000
6 Karthi Faculty M 35 06-JUL-98 350000
ENO NAME DES G AGE DOJ SALARY
------ ----------------- ---------- ---- -------- -------- ----------------
10 Kavin Guide M 19 18-JUN-11 15000
5 Naveen Lecturer M 27 27-NOV-16 15000
7 Sathya Lecturer F 24 22-AUG-17 16000
ENO NAME DES G AGE DOJ SALARY
------ ----------------- ---------- ---- -------- -------- ----------------
2 Selin Officer F 20 04-MAY-14 30000
10 rows selected.

SQL> update employee set des='Project Manager' where des='Lecturer';


3 rows updated.

SQL> select * from employee;


ENO NAME DES G AGE DOJ SALARY
----- ------------------ -------------------- -- -------- ------------ -------------
1 Alfiya Project F 19 30-JUN-15 25000
Manager
2 Selin Officer F 20 04-MAY-14 30000
3 Kalai Manager F 21 06-JUN-12 20000
ENO NAME DES G AGE DOJ SALARY
----- ------------------ -------------- -- -------- ------------ -------------
4 Akil Manager M 25 23-FEB-00 10000
5 Naveen Project M 27 27-NOV-16 15000
Manager
6 Karthi Faculty M 35 06-JUL-98 350000
ENO NAME DES G AGE DOJ SALARY
----- -------------- ------------ -- -------- ------------ -------------
7 Sathya Project F 24 22-AUG-17 16000
Manager
8 Hema Manager F 35 24-SEP-01 20000
9 Ashik Project M 26 27-FEB-13 18000
Manager
ENO NAME DES G AGE DOJ SALARY
----- ------------------ -------------------- -- -------- ------------ -------------
10 Kavin Guide M 19 18-JUN-11 15000

10 rows selected.
SQL> select salary,count(*)"salary" from employee group by salary;
SALARY salary
-------------- -----------
10000 1
30000 1
15000 2
16000 1
18000 1
25000 1
20000 2
35000 1
8 rows selected.
2.UPDATE TABLE USING PL/SQL

SQL> create table inv(prono number(10),proname varchar2(20),rate


number(10),constraint inv_prono_pk primary key(prono));
Table created.

SQL>desc inv;
Name Null? Type
----------------- --------- --------------------
PRONO NOT NULL NUMBER(10)
PRONAME VARCHAR2(20)
RATE NUMBER(10)

SQL> insert into inv values('&prono','&proname','&rate');


Enter value for prono:001
Enter value for proname:Dairy Milk
Enter value for rate:40
old 1:insert into inv values('&prono','&proname','&rate')
new 1:insert into inv values(‘1’,’Dairy Milk’,’40’)
1 row created.

SQL> /
Enter value for prono: 432
Enter value for proname:Galaxy
Enter value for rate:150
old 1:insert into inv values('&prono','&proname','&rate')
new 1:insert into inv values(‘432’,’Galaxy’,’150’)
1 row created.

SQL> /
Enter value for prono:576
Enter value for proname:Brooksite
Enter value for rate:250
old 1:insert into inv values('&prono','&proname','&rate')
new 1:insert into inv values(‘576’,’Brooksite’,’250’)
1 row created.

SQL> select * from inv;


PRONO PRONAME RATE
---------- --------------- ----------
001 Dairy Milk 40
432 Galaxy 150
576 Brooksite 250

SQL> begin
2 update inv set rate=rate+(rate*0.2);
3 commit;
4 end;
5 /
PL/SQL procedure successfully completed.

SQL> select * from inv;


PRONO PRONAME RATE
---------- ----------------- ----------
1 Dairy Milk 48
2 Galaxy 180
3 Brooksite 300

SQL> alter table inv add(noi number(10),place varchar2(20));


Table altered.

SQL> insert into inv values('&prono','&proname','&rate','&noi','&place');


Enter value for prono:306
Enter value for proname:Brooksite
Enter value for rate:350
Enter value for noi:3
Enter value for place: Mumbai
old 1:insert into inv values(‘&prono’,’&proname’,’&rate’,’&noi’,’&place’)
new 1:insert into inv values(‘306’,’Brooksite’,’350’,’3’,’Mumbai’)
1 row created.

SQL> /
Enter value for prono:147
Enter value for proname:Galaxy
Enter value for rate:200
Enter value for noi:7
Enter value for place:Chennai
old 1:insert into inv values(‘&prono’,’&proname’,’&rate’,’&noi’,’&place’)
new 1:insert into inv values(‘147’,’Galaxy’,’200’,’7’,’Chennai’)
1 row created.

SQL> /
Enter value for prono:674
Enter value for proname:Dairy Milk
Enter value for rate:100
Enter value for noi:10
Enter value for place:London
old 1:insert into inv values(‘&prono’,’&proname’,’&rate’,’&noi’,’&place’)
new 1:insert into inv values(‘674’,’Dairy Milk’,’100’,’10’,’London’)
1 row created.

SQL> select * from inv;


PRONO PRONAME RATE NOI PLACE
---------- -------------------- ---------- ---------- --------------------
1 Dairy Milk 48
432 Galaxy 180
576 Brooksite 300
306 Brooksite 350 3 Mumbai
147 Galaxy 200 7 Chennai
674 Dairy Milk 100 10 London
6 rows selected.

SQL> update inv set noi=3,place='Chennai' where proname='Brooksite';


1 row updated.

SQL> select * from inv;


PRONO PRONAME RATE NOI PLACE
---------- ------------------ ---------- ---------- ------------------
1 Dairy Milk 48
432 Galaxy 180
576 Brooksite 300
306 Brooksite 350 3 Chennai
147 Galaxy 200 7 Chennai
674 Dairy Milk 100 10 London
6 rows selected.

SQL> update inv set noi=2,place='Pune' where proname='Galaxy';


2 rows updated.

SQL> select * from inv;


PRONO PRONAME RATE NOI PLACE
---------- -------------------- ---------- ------- ------------------
1 Dairy Milk 48
432 Galaxy 180 2 Pune
576 Brooksite 300
306 Brooksite 350 3 Chennai
147 Galaxy 200 2 Pune
674 Dairy Milk 100 10 London
6 rows selected.
3. TRIGGERS

SQL> create table tri(id number(10)constraint tri_id_pk primary key,name


varchar2(20),supname varchar2(20),price number(10));
Table created.

SQL>desc tri;
Name Null? Type
------------ -------- ----------------------------
ID NOT NULL NUMBER(10)
NAME VARCHAR2(20)
SUPNAME VARCHAR2(20)
PRICE NUMBER(10)

SQL> insert into tri values('&id','&name','&supname','&price');


Enter value for id:1
Enter value for name:Aadhithya
Enter value forsupname:Aadhi
Enter value for price:170
old 1:insert into tri values(‘&id’,’&name’,’&supname’,’&price’)
new 1:insert into tri values(‘1’,’Aadhithya’,’Aadhi’,’170’)
1 row created.

SQL> /
Enter value for id:2
Enter value for name:Lavanya
Enter value for supname:Ammu
Enter value for price:250
old 1:insert into tri values(‘&id’,’&name’,’&supname’,’&price’)
new 1:insert into tri values(‘2’,’Lavanya’,’Ammu’,’250’)
1 row created.
SQL> select * from tri;
ID NAME SUPNAME PRICE
----- -------------------- -------------------- ----------
1 Aadhithya Aadhi 170
2 Lavanya Ammu 250

SQL> create table pri(id number(10),name varchar2(20),supname varchar2(20),price


number(10),constraint pri_id_fk foreign key(id) references tri(id));
Table created.

SQL>desc pri;
Name Null? Type
--------------- -------- ----------------------------
ID NUMBER(10)
NAME VARCHAR2(20)
SUPNAME VARCHAR2(20)
PRICE NUMBER(10)

SQL> create or replace trigger am before update of price on tri


2 for each row
3 begin
4 insert into pri values
5 (:old.id,
6 :old.name,
7 :old.supname,
8 :old.price);
9 end;
10 /
Trigger created.

SQL> update tri set price=500 where id=1;


1 row updated.

SQL> select * from tri;


ID NAME SUPNAME PRICE
------- ------------------ -------------------- ----------
1 Aadhithya Aadhi 500
2 Lavanya Ammu 250

SQL> select * from pri;


ID NAME SUPNAME PRICE
------ -------------------- -------------------- ----------
1 Aadhithya Aadhi 170

SQL> update tri set price=300 where id=2;


1 row updated.

SQL> select * from pri;


ID NAME SUPNAME PRICE
--------- ------------------- -------------------- ---------------
1 Aadhithya Aadhi 170
2 Lavanya Ammu 250

SQL> select * from tri;


ID NAME SUPNAME PRICE
----- -------------------- -------------------- ----------
1 Aadhithya Aadhi 500
2 Lavanya Ammu 300
4.PROCEDURES

SQL> SET SERVEROUTPUT ON

SQL> create table employee3(employeeid number(10)constraint


employee3_employeeid_pk primary key,fname varchar(10),lname varchar(10));Table
created.

SQL> desc employee3

Name Null? Type

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

EMPLOYEEID NOT NULL NUMBER(10)

FNAME VARCHAR2(10)

LNAME VARCHAR2(10)

SQL> insert into employee3 values('&employeeid','&fname','&lname');

Enter value for employeeid: 111

Enter value for fname: ashma

Enter value for lname: banu

old 1: insert into employee3 values('&employeeid','&fname','&lname')

new 1: insert into employee3 values('111','ashma','banu')

1 row created.

SQL> /

Enter value for employeeid: 112

Enter value for fname: nashathu

Enter value for lname: nisha


old 1: insert into employee3 values('&employeeid','&fname','&lname')

new 1: insert into employee3 values('112','nashathu','nisha')

1 row created.

SQL> /

Enter value for employeeid: 113

Enter value for fname: afrin

Enter value for lname: banu

old 1: insert into employee3 values('&employeeid','&fname','&lname')

new 1: insert into employee3 values('113','afrin','banu')

1 row created.

SQL> select* from employee3;

EMPLOYEEID FNAME LNAME

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

111 ashma banu

112 nashathu nisha

113 afrin banu

SQL> create or replace procedure search_emp

2 (i_empid in number,

3 o_first out varchar2,

4 o_last out varchar2)

5 is

6 begin

7 select fname,lname

8 into o_first,o_last

9 from employee3
10 where employeeid=i_empid;

11 exception

12 when others then

13 dbms_output.put_line('employeeid'||

14 to_char(i_empid)||'does not exist');

15 end search_emp;

16 /

Procedure created.

SQL> declare v_first employee3.fname%type;

2 v_last employee3.lname%type;

3 v_id employee3.employeeid%type:=&emp_id;

4 begin

5 search_emp(v_id,v_first,v_last);

6 if v_last is not null then

7 dbms_output.put_line('employee:'||v_id);

8 dbms_output.put_line('name:'||v_first||','||v_last);

9 end if;

10 end;

11 /

Enter value for emp_id: 112

old 3: v_id employee3.employeeid%type:=&emp_id;

new 3: v_id employee3.employeeid%type:=112;

employee:112

name:nashathu,nisha

PL/SQL procedure successfully completed.


5.PROJECT FOR STUDENT DATABASE

Private Sub Command1_Click()

Adodc1.Recordset.AddNew

End Sub

Private Sub Command2_Click()

Adodc1.Recordset.Delete

End Sub

Private Sub Command3_Click()

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

End Sub

Private Sub Command4_Click()

End

End Sub
SQL>create table student(regno number(5) CONSTRAINT student_regno_pk
primary key,name varchar2(10),m1 number(3),m2 number(3),total number(3));

Table created.

SQL>desc student;

Name Null? Type


------------ ---------------- ------------------
REGNO NOT NULL NUMBER(5)
NAME VARCHAR2(10)
M1 NUMBER(3)
M2 NUMBER(3)
TOTAL NUMBER(3)

SQL>insert into student values(‘&regno’,’&name’,&m1,&m2,&total);


Enter value for regno:234
Enter value for name:Aadhithya
Enter value for m1:98
Enter value for m2:97
Enter value for total:null
old 1: insert into student values(‘&regno’,’&name’,&m1,&m2,&total)
new 1:insert into student values(‘234’,’Aadhithya’,98,97,null)
1 row created.

SQL>/
Enter value for regno:235
Enter value for name:Benita
Enter value for m1:98
Enter value for m2:87
Enter value for total:null
old 1:insert into student values(‘&regno’,’&name’,&m1,&m2,&total)
new 1:insert into student values(‘235’,’Benita’,98,87,null)
1 row created.
SQL>/
Enter value for regno:236
Enter value for name:Lakshmi
Enter value for m1:76
Enter value for m2:85
Enter value for total:null
old 1:insert into student values(‘&regno’,’&name’,&m1,&m2,&total)
new 1:insert into student values(‘236’,’Lakshmi’,76,85,null)
1 row created.

SQL>select * from student;


REGNO NAME M1 M2 TOTAL
----------- ---------- ----- ---- -----------
234 Aadhithya 98 97
235 Benita 98 87
236 Lakshmi 76 85

SQL>select * from student;


REGNO NAME M1 M2 TOTAL
----------- ---------- ----- ---- -----------
234 Aadhithya 98 97
235 Benita 98 87
236 Lakshmi 76 85
237 Raji 98 98 196
SQL>select * from student;
REGNO NAME M1 M2 TOTAL
----------- ---------- ----- ---- -----------
234 Aadhithya 98 97
235 Benita 98 87
236 Lakshmi 76 85
238 Ragavi 88 97 185
OUTPUT

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