vb oracle record
TRANSCRIPT
MADURAI KAMARAJ UNIVERSITY
BACHELOR OF COMPUTER APPLICATIONS
PROGRAMMING IN VISUAL BASIC AND ORACLE
(Practical Lab –I)
Submitted by
NAME :
EN.NO. :
CLASS :
MADURAI KAMARAJ UNIVERSITY
Palkalai Nagar, Madurai-625 021
BCA-DISTANCE LEARNING PROGRAMME
BONAFIDE CERTIFICATE
ENROLMENT NUMBER
Certified that this is the bonafide record of work done by _____________________-
________ of the BCA (Batch No.____) -_______Lab for the year 2007-2008 at the
Madurai Kamaraj University (Distance Education) Admission centre, No.11/6,
Bakthavataslam Street, P.M.Apartment, West Tambram, Chennai-45.
Staff-in-Charge Co-ordinator
Submitted for the University Practical Examination held on _______.2009 at the
Madurai Kamaraj University (Distance Education) Admission Centre, No.11/6,
Bakthavatsalam Street, P.M.Apartment, West Tambaram, Chennai -45.
Internal Examiner
External Examiner
CONTENTS
PROGRFAMING IN VISUAL BASIC
Ex.No
Date Particulars Page no
Signature
1. Addition,SubstractionMultiplication Output
2.Fibonacci Series Output
3.Factorial Output
4. Calculator Output
5.Employee Details
CONTENTS
PROGRFAMING IN ORACLE
Ex.No Date Particulars Page no
Signature
1. Print deptno,empno,sal with condition
2. Update salary by 10% for a employee
3.Update a column based on multiple condition
4. Question using cursors
5 Check for duplication
Writing a Visual Basic Program to Addition,
Subtraction Multiplication and Division
Ex No: 1
Date:
Aim: -
Write a program to implement writing an Addition, Subtraction, Multiplication and Division
Output
Algorithm: -
Step 1 – To start the Visual Basic program
Step 2 – Initialize the program.
Step 3 – Declare the main program.
Step 4 – Using Program to writing a Addition, Subtraction, Multiplication and Division.
Step 5 – To save and compile the program.
Step 6 – Run the program.
Step 7 – To stop the program.
1. Write a visual Basic Program to Addition, Substraction, Multiplication and Division
Source Code:
Private Sub Command1_Click()Text3.Text=val(Text1.Text)+Val(Text2.Text)
End Sub
Private Sub Command2_Click()Text3.Text=val(Text1.Text) - Val(Text2.Text)End Sub
Private Sub Command3_Click()Text3.Text=val(Text1.Text) * Val(Text2.Text)End Sub
Private Sub Command4_Click()Text3.Text=val(Text1.Text) / Val(Text2.Text)End Sub
Form:
OUTPUT SCREEN:
Write a Visual Basic Program to Print a Fibonacci
series
Ex No: 2
Date:
Aim: -
Write a Visual basic program to print a Fibonacci series
Algorithm: -
Step 1 – To start the Visual Basic program
Step 2 – Initialize the program.
Step 3 – Declare the main program.
Step 4 – Using Program to writing a Visual basic program to print a Fibonacci series
Step 5 – To save and compile the program.
Step 6 – Run the program.
Step 7 – To stop the program.
2. Write a visual Basic Program to print a Fibonacci series:
Source Code:Private Sub Command1_click()Dim X As IntegerX=InputBOX(“Enter the value(greater than 1)”)Dim oi,n,c As IntegerOi=0N=1Print”The fibo is as follows”Print oiPrint nFor l=1 To X-2C=oi+nPrint cOi=nN=cNext lEnd Sub
Form:
OUTPUT SCREEN:
Write a Visual Basic Program to calculate Factorial of the given value
Ex No: 3
Date:
Aim: -
Write a Visual Basic Program to calculate Factorial of the given value
Algorithm: -
Step 1 – To start the program.
Step 2 – Initialize the Program.
Step 3 – Declare the main program.
Step 4 – writing a Visual Basic Program to calculate Factorial of the given value
Step 5 – To save and compile the program.
Step 6 – Run the program.
Step 7 – To stop the program.
3. Write a Visual Basic Program to calculate Factorial of the given value
Source Code:
Private Sub Command1_Click()Dim X As IntegerDim oi,n,c As IntegerOi=0N=1X=InputBox(“Enter the Value”)Print “The Fact value is…..”For I = 1 To X N=n * iNext iPrint nEnd Sub
Form :
OUTPUT SCREEN:
Write a visual Basic Program to create
calculator
Ex No: 4
Date:
Aim: -
Write a visual Basic Program to create calculator.
Algorithm: -
Step 1 – To start the program.
Step 2 – Initialize the Program.
Step 3 – Declare the main program.
Step 4 – writing a Visual Basic Program to create calculator
Step 5 – To save and compile the program.
Step 6 – Run the program.
Step 7 – To stop the program.
4. Write a visual Basic Program to create calculator
Source Code:Dim SDim OP As String
Private Sub Command1_Click()Text1.Text=Text1.Text + Command1.CaptionEnd Sub
Private Sub Command2_Click()Text1.Text=Text1.Text + Command2.CaptionEnd Sub
Private Sub Command3_Click()Text1.Text=Text1.Text + Command3.CaptionEnd Sub
Private Sub Command4_Click()Text1.Text=Text1.Text + Command4.CaptionEnd SubPrivate Sub Command5_Click()Text1.Text=Text1.Text + Command5.CaptionEnd Sub
Private Sub Command6_Click()Text1.Text=Text1.Text + Command6.CaptionEnd Sub
Private Sub Command7_Click()Text1.Text=Text1.Text + Command7.CaptionEnd Sub
Private Sub Command8_Click()Text1.Text=Text1.Text + Command8.CaptionEnd Sub
Private Sub Command9_Click()Text1.Text=Text1.Text + Command9.CaptionEnd SubPrivate Sub Command10_Click()Text1.Text=Text1.Text + Command10.CaptionEnd Sub
Private Sub Command11_Click()
S=Text1.TextOP=Command11.CaptionText1.Text=””End Sub
Private Sub Command12_Click()S=Text1.TextOP=Command12.CaptionText1.Text=””End Sub
Private Sub Command13_Click()S=Text1.TextOP=Command13.CaptionText1.Text=””End SubPrivate Sub Command14_Click()S=Text1.TextOP=Command14.CaptionText1.Text=””End Sub
Private Sub Command15_Click()S=Text1.TextOP=Command15.CaptionText1.Text=””End SubPrivate Sub Command16_Click()If OP =”+” Then Text1.Text=Val(Text1.Text) + Val(S)Elself OP=”-“ Then Text1.Text=Val(S) – Val(Text1.Text)Elself OP=” * “ Then Text1.Text=Val(S) * Val(Text1.Text)Elself OP=” / “ Then Text1.Text=Val(S) / Val(Text1.Text)Elself OP=”SQRT” Then Text1.Text=Sqr(Val(Text1.Text))End If
End Sub
Private Sub Command17_Click()Text1.Text=””End Sub
Form :
OUTPUT SCREEN :
Write a Visual Basic Program Employee Details
Ex No: 5
Date:
Aim: -
Write a Visual Basic Program Employee Details
Algorithm: -
Step 1 – To start the program.
Step 2 – Initialize the program.
Step 3 – Declare the main program.
Step 4 – writing a Visual Basic Program Employee Details
Step 5 – To save and compile the program.
Step 6 – Run the program.
Step 7 – To stop the program.
5. Write a Visual Basic Program Employee Details
Source Code:
Public RSTem As RecordsetPublic DBSEMP As DatabasePrivate Sub Command1_Click()Command1.Enabled=FalseCommand2.Enabled=TrueOption1.Visible=FalseOption2.Visible=TrueEnd Sub
Private Sub Command2_click()If Command3.Tag<>”EDIT”ThenRSTem.AddNewElseRSTem.EditEnd IfRSTem.Fields(“ENO”).Value=Text2.TextRSTem.Fields(“ENAME”).Value=Text1.TextIf Option1.Value=True Then RSTem.Fields(“SEX”).Value=”Male”Else RSTem.Fields(“SEX”).Value=”FeMale”End IfRSTem.Fields(“basicpay”).Value=Text3.TextRSTem.Fields(“department”).Value=Text4.Text RSTem.UpdateCommand2.Enabled=FalseCommand1.Enabled=TrueEnd Sub
Private Sub Command3_click()Command2.Enabled = True x = InputBox(“Enter Employee No.:”)RSTem.Index = “PRIMARYKEY”RSTem.Seek”=”,xIf RSTem.NoMatch=False Then Text1.Text=RSTem.Fields(“ENO”).Value Text2.Text=RSTem.Fields(“ENAME”).ValueIf RSTem.Fields(“SEX”).Value=”Male”Then Option1.Value=True Option2.Value=FalseElse Optin1.Value=False Option2.Value=TrueEnd If
Text3.Text=RSTem.Fields(“basicpay”).Value Text4.Text=RSTem.Fields(“department”).ValueEnd If
Command3.Tag = “EDIT”‘Text5.Visible=TrueOption1.Visible=FalseOption2.Visible=FalseEnd Sub
Private Sub Command4_click()Data1.Recordset.DeleteData1.Recordset.MoveNextEnd Sub
Private Sub Form_load()Set DBSEMP = OpenDatabase(“D:\kbln project\emp.MDB”)Set RSTem=DBSEMP.OpenRecordset(“employeemst”)End Sub
Private Sub Option1_click()‘Text5.Text=”Male”End Sub
Private Sub Option2_click()‘Text5.Text=”FEMALE”End Sub
DATABASE IN ACCESS:
Form:
OUTPUT SCREEN:
ORACLE
Print the DEPTNO,EMPNO,SAL from emp where
ename=’SMITH’
Ex No: 1
Date :
Aim: -
Write a program to implement Print the DEPTNO,EMPNO,SAL from emp where ename=’SMITH’.
Algorithm: -
Step 1 – To start the program
Step 2 – Initialize the program.
Step 3 – Declare the main program.
Step 4 – Using Program to Print the DEPTNO,EMPNO,SAL from emp where ename=’SMITH’.
Step 5 – To save and compile the program.
Step 6 – Run the program.
Step 7 – To stop the program.
1. Print the DEPTNO,EMPNO,SAL from emp where ename=’SMITH’.
Source Code:
Declare
Vename varchar2(15);
Vdeptno number;
Vempno number;
Vsal number;
Begin
Select ename deptno,empno,sal into vename vdeptno,vsal
From emp where ename =’SMITH’;
dbms_output.line(‘DEPNO ‘II’ EMPNO ‘II’ SALARY’);
dbms_output.line(vdeptno,vempno,vsal);
OUTPUT:
DEPTNO II EMPNO II SALARY
10001 1234 15000
10024 0954 12000
10005 1456 24000
3 rows selected
Upgrade the salary of a employee by 10% of its original salary.Print the old salary as well as new salary.Accept ename as runtime Parameter
Ex No: 2
Date:
Aim: -
Write a program to implement writing Upgrade the salary of a employee by 10% of its original salary.Print the old salary as well as new salary.Accept ename as runtime Parameter
Algorithm: -
Step 1 – To start the program
Step 2 – Initialize the program.
Step 3 – Declare the main program.
Step 4 – Using Program to writing Upgrade the salary of a employee by 10% of its original salary.Print the old salary as well as new salary.Accept ename as runtime Parameter
Step 5 – To save and compile the program.
Step 6 – Run the program.
Step 7 – To stop the program.
2. Upgrade the salary of a employee by 10% of its original salary.Print the old salary as well as new salary.Accept ename as runtime Parameter
Declare
Vsal number; Vempno number; Vename varchar2(15); Vdeptno number;Begin Vempno :=&n; Select ename,deptno,empno,sal into vename,vdeptno,vempno,vsal from emp Where empno = vempno;Dbms_output.put_line(‘Old Salary ‘||vsal);Vsal := vsal + (0.1 * vsal);Update emp Set sal = vsal Where empno=vempno;Dbms_output.put_line(‘New salary : ‘||vsal);End;
OUTPUT :
>Enter the Value :>1001 Old Salary :10000 New Salary:11000
1 rows selected.
(Assuming the employee with the id no.1001 present salary Rs.10000/-)
Update the comm. Column of all employee if
Ex No: 3
Date:
Aim: -
Write a program to implement Update the comm. Column of all employee if
Algorithm: -
Step 1 – To start the program
Step 2 – Initialize the program.
Step 3 – Declare the main program.
Step 4 – Using Program to writing an Addition, Subtraction, Multiplication and Division.
Step 5 – To save and compile the program.
Step 6 – Run the program.
Step 7 – To stop the program.
3. Update the comm. Column of all employee if
Salary is > 1000 then comm =500, Salary is > 2000 then comm =1000, Salary is > 3000 then comm =2000 Use for I in (select * from emp)
Declare Vsal number; Vename varchar2(15) Vdeptno number; Vcomm number; Vempno number;Begin
For I in (select * from emp)Loop Select sal,empno,ename,comm. From emp where i.empno=empno; If vsal > 3000 then Vcomm :=2000;
Elseif vsal > 2000 then Vcomm :=1000; Else Vcomm :=500;EndifUpdate empSetcomm=vcomm where 1.empno=empno;Dbms_output.put_line(‘Commission :’||vcomm);End loop;End;
OUTPUT:
COMMISSION : 1000
1 rows selected
Do the above question using cursors
Ex No: 4
Date:
Aim: -
Write a program to implement Do the above question using cursors
Algorithm: -
Step 1 – To start the program
Step 2 – Initialize the program.
Step 3 – Declare the main program.
Step 4 – Using Program to writing Do the above question using cursors.
Step 5 – To save the program.
Step 6 – Run the program.
Step 7 – To stop the program.
4. Do the above question using cursors
Declare
vempno emp.empno%type;
vcomm emp.comm%type;
vsal emp.sal%type;
vename emp.ename%type;
cursor AAA is select empno,ename,sal,comm from emp;
begin
open AAA;
loop
fetch AAA into vempno,vename,vsal,vcomm;
exit when AAA%notfound;
if vsal>3000 then
vcomm :=1000;
else vcomm :=500;
end if;
update emp set comm.=vcomm
where empno = vempno;
dbms_output.put_line(‘Ename ‘II ‘Commission’);
dbms_output.put_line(vename II ‘ ‘ II vcomm);
end loop;
close AAA;
end;
OUTPUT:
ENAME II Commission
------------------------------------------
SAM 1000
RAJ 500
RAJU 1000
3 rows selected.
Check for Duplication for the key field Empno
Ex No: 5
Date:
Aim: -
Check for Duplication for the key field Empno
Algorithm: -
Step 1 – To start the program
Step 2 – Initialize the program.
Step 3 – Declare the main program.
Step 4 – Check for Duplication for the key field Empno
Step 5 – To save the program.
Step 6 – Run the program.
Step 7 – To stop the program.
5. Check for Duplication for the key field Empno
Declare
Vempno emp.empno%type := &empno;
Vempno emp.empname%type := &vename;
Vsal emp.sal%type := &vsal;
Vdeptno emp.deptno%type := &vdeptno;
n number
begin
select count(*) into n from emp
where empno=vempno;
if n>0 then
dbms_output.putline(‘Duplicate empno’);
else
insert into emp(empno,ename,sal,deptno)
values (vempno,vename,vsal,vdeptno);
end if;
end;
OUTPUT:
This will accept employee details from curser and check for duplicate empno from the table emp and if duplication is not there then insert a record to the table.