Vous êtes sur la page 1sur 86

1

EX.NO: 1 DATE:20.06.13
AIM:

NUMBER CONVERSION

To write a visual basic program to accept a number as input and convert them into a. Binary b. Octal c. Hexadecimal

ALGORITHM: Step1: Start the process. Step2: Click start-> all programs->microsoft visual studio 6.0-> visual basic 6.0. Step3: Select stansard.exe and open a new project window with from. Step4.Design the form 4 labels and 4 textboxes and 4 buttons. Step5: Enter the entity inside the text boxes Step6: Convert to values binary, octal and hexadecimal values. Step7: Stop the process.

FORM DESIGN:

SOURCE CODE: Private Sub Command1_Click() Text2 = "" n = Val(Text1) Do While (n <> 0) a = n Mod 2 Text2 = Str(a) + Text2 n = Int(n / 2) Loop End Sub Private Sub Command2_Click() Text2 = "" n = Val(Text1) Do While (n <> 0) a = n Mod 8 Text2 = Str(a) + Text2 n = Int(n / 8) Loop End Sub Private Sub Command3_Click() Text2 = "" n = Val(Text1)

Do While (n <> 0) a = n Mod 16 Select Case a Case 10 Text2 = "a" + Text2 Case 11 Text2 = "b" + Text2 Case 12 Text2 = "c" + Text2 Case 13 Text2 = "d" + Text2 Case 14 Text2 = "e" + Text2 Case 15 Text2 = "f" + Text2 Case Else Text2 = Str(a) + Text2 End Select n = Int(n / 16) Loop End Sub

OUTPUT:

Result: Thus the above program has been executed and verified successfully.

EX.NO: 2 DATE:26.06.13
AIM:

ADD THE ITEMS

To write a visual basic program to add the items to list box with user input and move the select item to combo box one by one. ALGORITHM: Step1: Start the process. Step2: Click Start-> All programs->Microsoft visual studio 6.0-> visual basic 6.0. Step3: Select stansard.exe and open a new project window with from. Step4: Design from with one label box, text box, List box, combo box and Command buttons and set their properties. Step5: Move the selected list item into the combo box using property add item (list, text1). Step6: Stop the process.

FORM DESIGN:

SOURCE CODE: Private Sub Command1_Click() Combo1.AddItem (Text1.Text) Text1 = "" End Sub

Private Sub Command2_Click() List1.AddItem (Combo1.Text) End Sub

Private Sub Command3_Click() End End Sub

OUTPUT:

Result: Thus the above program has been executed and verified successfully.

10

EX.NO: 3 DATE:08.07.13

CALCULATOR

AIM: To write a visual basic program to develop a calculator with basic operations. ALGORITHM: Step1: Start the process. Step2: Click Start-> All programs->Microsoft visual studio 6.0-> visual basic 6.0. Step3: Select stansard.exe and open a new project window with from. Step4: Design the form with one textbox and seven command buttons, command 1 copy of commands is used to display numbers. Step5: Perform the require calculations using arithmetic operations. Step6: Stop the process.

11

FORM DESIGN:

12

SOURCE CODE: Dim n As Integer Dim sign As String

Private Sub Command1_Click(Index As Integer) Text1 = Text1 + Command1(Index).Caption End Sub

Private Sub Command2_Click() n = Val(Text1) Text1 = "" sign = "+" End Sub

Private Sub Command3_Click() n = Val(Text1) Text1 = "" sign = "-" End Sub

Private Sub Command4_Click() n = Val(Text1) Text1 = "" sign = "*"


13

End Sub

Private Sub Command5_Click() n = Val(Text1) Text1 = "" sign = "/" End Sub

Private Sub Command6_Click() n=0 Text1 = "" End Sub

Private Sub Command7_Click() Select Case sign Case "+" Text1 = n + Val(Text1) Case "-" Text1 = n - Val(Text1.Text) Case "*" Text1 = n * Val(Text1.Text) Case "/" Text1 = n / Val(Text1.Text) End Select End Sub
14

OUTPUT:

Result: Thus the above program has been executed and verified successfully.

15

EX.NO: 4 DATE:18.07.13
AIM: To write a visual basic program to design form using common dialog box control to display font, save, new, open without using the action control property. ALGORITHM: Step1: Start the process. Step2: Click Start-> All programs->Microsoft visual studio 6.0-> visual basic 6.0. Step3: Select stansard.exe and open a new project window with from. Step4: Click the project menu bar-> components and select these two control added to tool bar. Step5: Draw two controls to use common dialog control methods. Step6: Stop the process.

DIALOG BOX CREATION

16

FORM DESIGN:

17

SOURCE CODE: Private Sub font_Click() CommonDialog1.Flags = cdlCFBoth Or cdlCFEffects CommonDialog1.ShowFont RichTextBox1.SelFontName = CommonDialog1.FontName RichTextBox1.SelFontSize = CommonDialog1.FontSize RichTextBox1.SelBold = CommonDialog1.FontBold RichTextBox1.SelUnderline = CommonDialog1.FontUnderline RichTextBox1.SelColor = CommonDialog1.Color End Sub Private Sub new_Click() RichTextBox1.Text = "" End Sub

Private Sub open_Click() CommonDialog1.Filter = "textfile(*.txt)" CommonDialog1.ShowOpen RichTextBox1.LoadFile (CommonDialog1.FileName) End Sub

Private Sub save_Click() CommonDialog1.Filter = "textfile.text" CommonDialog1.ShowSave RichTextBox1.SaveFile (CommonDialog1.FileName) End Sub
18

OUTPUT:

Result: Thus the above program has been executed and verified successfully.
19

EX.NO: 5 DATE:24.07.13
AIM:

QUESTIONNAIRES

To write a visual basic program to prepare a questionnaires. ALGORITHM: Step1: Start the process. Step2: Click Start-> All programs->Microsoft visual studio 6.0-> visual basic 6.0. Step3: Select stansard.exe and open a new project window with from. Step4: Design the form using required controls. Step5: Click your answer and get the source. Step6: Stop the process.

20

FORM DESIGN:

21

SOURCE CODE: Private Sub Command1_Click() Dim q1, q2, q3, q4, q5, marks As Integer q1 = 0 q2 = 0 q3 = 0 q4 = 0 q5 = 0 If Option2 = True Then q1 = 10 End If If Option3 = True Then q2 = 10 End If If Option5 = True Then q3 = 10 End If If Option8 = True Then q4 = 10 End If If Option9 = True Then q5 = 10 End If marks = q1 + q2 + q3 + q4 + q5 Select Case marks
22

Case 10 Label7.Caption = marks Label8.Caption = "not selected" Case 20 Label7 = marks Label8 = "not selected" Case 30 Label7 = marks Label8 = "waiting.." Case 40 Label7 = marks Label8 = "selected" Case 50 Label7 = marks Label8 = "selected" End Select End Sub

23

OUTPUT:

Result: Thus the above program has been executed and verified successfully.

24

EX.NO: 6 DATE:02.08.13
AIM:

MENU CREATION

To write a visual basic program to develop a menu driven adds a menu driven window in the form horizontal style using menu. ALGORITHM: Step1: Start the process. Step2: Click Start-> All programs->Microsoft visual studio 6.0-> visual basic 6.0. Step3: Select standard.exe and open a new project window with from. Step4: Design the form using menu editor menu. Step5: Include add from change the cascade of form and apply a color to the form by using submenu. Step6: Stop the process.

25

FORM DESIGN:

26

SOURCE CODE: Private Sub af_Click() Dim newform As New Form1 newform.Show End Sub

Private Sub clr_Click() CommonDialog1.ShowColor Me.BackColor = CommonDialog1.Color End Sub

Private Sub cs_Click() Me.Arrange vbCascade End Sub

Private Sub ex_Click() End End Sub

Private Sub hor_Click() MDIForm1.Arrange vbHorizontal End Sub

27

OUTPUT:

1. Cascade view:

28

2. Horizontal view:

Result: Thus the above program has been executed and verified successfully.

29

30

EX.NO: 1 DATE:09.08.13

DISPLAY TOOLBAR & STATUS BAR

AIM: To create VC++ program to display toolbar and status bar status. PROCEDURE: Step1: Start-> all programs ->visual studio 6.0->Microsoft visual c++ Step2: Select file-> new and choose option MFC application wizard (exe) and give project name. Step3: Click next option and select project type as single document interface and finally press finish button. Step4: New an empty project is created new we needed to design our toolbar. Step5: Select resource view from left side of window from that choose toolbar option and select string ID_DRAW_RECTANGLE, ID_DRAW_ELLIPS, ID_DRAW_TRIANGLE. Step6: Selecting class wizard (ctrl+w) add message map for rectangle, ellipse and triangle. Step7: Write a source code for a program. Step8: Compile and execute program.

31

FORM DESIGN:

32

SOURCE CODE: void CPrg1View::OnDrawRectangle() { CClientDC* pDC; pDC=new CClientDC(this); pDC->Rectangle(100,100,170,150); } void CPrg1View::OnDrawEllipse() { CClientDC* pDC; pDC=new CClientDC(this); pDC->Ellipse(10,10,200,100); } void CPrg1View::OnDrawTriangle() { CClientDC* pDC; pDC=new CClientDC(this); pDC->MoveTo(200,200); pDC->LineTo(300,300); pDC->LineTo(150,300); pDC->LineTo(200,200); pDC->SetBkColor(RGB(0,0,255)); pDC->TextOut(200,250,"vengat Vc++"); }
33

OUTPUT:

Result: Thus the above program has been executed and verified successfully.

34

EX.NO: 2 DATE:19.08.13

ADD & DELETE STRING IN LISTBOX

AIM: To create VC++ program adding and deleting a string in list box.

PROCEDURE: Step1: Start-> all programs ->visual studio 6.0->Microsoft visual c++ Step2: Select file-> new and choose option MFC application wizard (exe) and give project name as list box. Step3: Click next option select dialog based application as project Step4: Finally press finish button new an empty dialog application is created. Step5: Write a source code for a program. Step6: Compile and executed the program.

35

FORM DESIGN:

36

SOURCE CODE: void CPrg2Dlg::OnButton1() { UpdateData(TRUE); CString a; m_text.GetWindowText(a); m_list.AddString(a); MessageBox("ADDED"); m_text.SetWindowText(" "); UpdateData(false); } void CPrg2Dlg::OnButton2() { m_list.DeleteString (m_list.GetCurSel ()); MessageBox("DELETED"); }

37

OUTPUT:

Result:

Thus the above program has been executed successfully and verified.

38

EX.NO: 3 DATE:27.08.13
AIM: To develop VC++ program for menu editor. PROCEDURE:

MENU EDITOR

Step1: Start-> all programs ->visual studio 6.0->Microsoft visual c++. Step2: Select file-> new and choose option MFC application wizard (exe) and give project name as menu bar. Step3: Click next option and select project type as simple document interface and finally press finish button. Step4: Now an empty project is created menu we needed to design our menu. Step5: Select resource view from left side of window from that chooses menu option and design. Step6: Write a source code for a program. Step7: Compile and execute the program.

39

FORM DESIGN:

40

SOURCE CODE: void CMainFrame::OnDrawRectangle() { CClientDC* pDC; pDC=new CClientDC(this); pDC->Rectangle(100,100,180,140); } void CMainFrame::OnDrawEllipse() { CClientDC* pDC; pDC=new CClientDC(this); pDC->Ellipse(30,40,120,70); } void CMainFrame::OnDrawTriangle() { CClientDC* pDC; pDC=new CClientDC(this); pDC->MoveTo(200,200); pDC->LineTo(300,300); pDC->LineTo(150,300); pDC->LineTo(200,200); }

41

OUTPUT:

Result: Thus the above program has been executed and verified successfully.

42

EX.NO: 4 DATE:02.09.13

FREE HAND DRAWING

AIM: To create VC++ application program to perform free hand drawing. PROCEDURE: Step1: Start-> all programs ->visual studio 6.0->Microsoft visual c++. Step2: Select file-> new and choose option MFC application wizard (exe) and give project name as HAND drawing. Step3: Click next option select dialog based application as project Step4: Finally press finish button new an empty dialog application is created. Step5: Write a source code for a program. Step6: Compile and executed the program

43

FORM DESIGN:

44

SOURCE CODE: int flag = 0, x1, x2, y1, y2; void CPrg3Dlg::OnLButtonDown(UINT nFlags, CPoint point) { if (flag == 0) { x1 = point.x; y1 = point.y; flag = 1; } CDialog::OnLButtonDown(nFlags, point); } void CPrg3Dlg::OnLButtonUp(UINT nFlags, CPoint point) { flag = 0; CDialog::OnLButtonUp(nFlags, point); } void CPrg3Dlg::OnMouseMove(UINT nFlags, CPoint point) { if ( flag == 1) { x2 = point.x; y2 = point.y; CClientDC dc(this);
45

dc.MoveTo (x1, y1); dc.LineTo (x2, y2); x1 = x2; y1 = y2; } CDialog::OnMouseMove(nFlags, point); } void CPrg3Dlg::OnCancel() { CDialog::OnCancel (); CDialog::OnCancel(); }

46

OUTPUT:

Result: Thus the above program has been executed and verified successfully.

47

EX.NO: 5 DATE:18.09.13
AIM:

SERIALIZATION-SDI

To create VC++ program to perform SERTALRATION-SDI. PROCEDURE: Step1: Start-> all programs ->visual studio 6.0->Microsoft visual c++. Step2: Select file-> new and choose option MFC application wizard (exe) and give project name as menu bar. Step3: Click next option and select project type as simple document interface and finally press finish button. Step4: Selecting ctrl+w have included VM_CHAR function for reading character from user. Step5: Write a source code for a program. Step6: Compile and execute the program.

48

FORM DESIGN:

49

SOURCE CODE: Sdidoc.h: class CSdiDoc : public CDocument { protected: // create from serialization only CSdiDoc(); DECLARE_DYNCREATE(CSdiDoc) // Attributes public: CString text;

sdiDoc.cpp CSdiDoc::CSdiDoc() { text=" "; } void CSdiView::OnDraw(CDC* pDC) { CSdiDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); pDC->TextOut(50,50,pDoc->text); } void CSdiView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { CSdiDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); pDoc->text+=nChar; CView::OnChar(nChar, nRepCnt, nFlags); }

50

OUTPUT:

Result: Thus the above program has been executed and verified successfully.

51

EX.NO: 6 DATE:30.09.13
AIM:

SERIALIZATION-MDI

To create VC++ program to perform SERTALRATION-MDI. PROCEDURE: Step1: Start-> all programs ->visual studio 6.0->Microsoft visual c++. Step2: Select file-> new and choose option MFC application wizard (exe) and give project name. Step3: Click next option and select project type as multiple document interfaces and finally press finish button. Step4: Selecting ctrl+w have included VM_CHAR function for reading character from user. Step5: Write a source code for a program. Step6: Compile and execute the program.

52

FORM DESIGN:

53

SOURCE CODE:
mdidoc.h: public:

int m_posx; int m_posy;


mddiDoc.cpp: void CMddiDoc::Serialize(CArchive& ar) { if (ar.IsStoring()) {

ar << m_posx << m_posy;


} else {

ar >> m_posx >> m_posy; } }


mddiView.cpp: void CMddiView::OnDraw(CDC* pDC) { CMddiDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc);

RECT br; br.left = m_posx - 50; br.right = m_posx + 50; br.bottom = m_posy - 50; br.top = m_posy + 50; pDC->Ellipse(&br);
}

void CMddiView::OnInitialUpdate() { CView::OnInitialUpdate();

CMddiDoc* pDoc; pDoc = GetDocument(); m_posx = pDoc->m_posx ; m_posy = pDoc->m_posy; }


void CMddiView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)

{ CMddiDoc* pDoc;
54

pDoc = GetDocument(); m_posx = pDoc->m_posx ; m_posy = pDoc->m_posy ; InvalidateRect(NULL); }


void CMddiView::OnLButtonDown(UINT nFlags, CPoint point)

{ m_posx = point.x; m_posy = point.y; CMddiDoc* pDoc; pDoc = GetDocument(); pDoc->m_posx = m_posx; pDoc->m_posy = m_posy; InvalidateRect(NULL); pDoc->UpdateAllViews (this); pDoc->SetModifiedFlag (TRUE);
CView::OnLButtonDown(nFlags, point);

55

OUTPUT:

Result: Thus the above program has been executed and verified successfully.

56

57

EX.NO: 1 DATE:27.06.13

DATA DEFINITION BASICS

AIM: To create six tables and make constraint for the ticket_ no in table5 and add new column fare to the table3 with data type as long.

ALGORITHM: STEP 1: Start the process STEP 2: Create six tables and display the structure. STEP 3: Constraint is added into ticket_no from the table5 and check ticket_no between 1 & 500. STEP 4: New column is added to the table3, and the description is displayed. STEP 5: Stop the Process.

58

SQL> create table christo1(cat_code number(3) primary key); Table created. SQL> desc christo1; Name Null? Type

----------------------------------------- -------- ---------------------------CAT_CODE NOT NULL NUMBER(3)

SQL> create table christo2(place_id number(3) primary key, bus_station varchar2(10)); Table created. SQL> desc christo2; Name Null? Type

----------------------------------------- -------- ---------------------------PLACE_ID BUS_STATION NOT NULL NUMBER(3) VARCHAR2(10)

SQL> create table christo3(rout_id number(3) primary key, cat_code number(3),orgin varchar2(10), destination varchar2(10),distance_kms number(4)); Table created. SQL> desc christo3; Name Null? Type

----------------------------------------- -------- ---------------------------ROUT_ID CAT_CODE ORGIN DESTINATION DISTANCE_KMS NOT NULL NUMBER(3) NUMBER(3) VARCHAR2(10) VARCHAR2(10) NUMBER(4)

59

SQL> create table christo4(route_id number(3), place_id number(3), day varchar(10)); Table created. SQL> desc christo4; Name Null? Type

----------------------------------------- -------- ---------------------------ROUTE_ID PLACE_ID DAY NUMBER(3) NUMBER(3) VARCHAR2(10)

SQL> create table christo5(ticket_no number(3) primary key, no_of_ticket number(4)); Table created. SQL> desc christo5; Name Null? Type

----------------------------------------- -------- ---------------------------TICKET_NO NO_OF_TICKET NOT NULL NUMBER(3) NUMBER(4)

SQL> create table christo6(ticket_no number(3),passenger_name varchar2(10),gender varchar2(6),age number(3),seat_no number(3),amount number(5)); Table created. SQL> desc christo6; Name Null? Type

----------------------------------------- -------- --------------TICKET_NO PASSENGER_NAME GENDER AGE NUMBER(3) VARCHAR2(10) VARCHAR2(6) NUMBER(3)

60

SEAT_NO AMOUNT

NUMBER(3) NUMBER(5)

SQL> alter table christo5 add constraint ck_ticketno check(ticket_no between 1 and 500); Table altered. SQL> alter table christo3 add(fare long); Table altered. SQL> desc christo3; Name Null? Type

----------------------------------------- -------- ---------------------------ROUT_ID CAT_CODE ORGIN DESTINATION DISTANCE_KMS FARE NOT NULL NUMBER(3) NUMBER(3) VARCHAR2(10) VARCHAR2(10) NUMBER(4) LONG

Result: Thus the above queries has been executed and verified successfully.

61

EX.NO: 2 DATE:03.07.13

DATA MANIPULATION BASICS

AIM: Insert values for six tables and display the table with original and destination catcode from rh5 table and update fare as 500 to distance between Ooty and Chennai. ALGORITHM: STEP 1: Start the process. STEP 2: Values are inserted into six table displayed the table with the route displayed the table with the route origin form Madras and destination By select query. STEP 3: Catcode column was displayed from the Table with descending order. STEP 4: The distance was update into 500 for origin Madras to destination Cochin from the table and displayed. STEP 5: Stop the Process.

62

SQL> insert into christo1 values(100); 1 row created. SQL> insert into christo1 values(200); 1 row created. SQL> insert into christo1 values(300); 1 row created. SQL> insert into christo1 values(400); 1 row created. SQL> insert into christo1 values(500); 1 row created. SQL> select * from christo1; CAT_CODE ---------100 200 300 400 500 SQL> insert into christo2 values(11,'coimbatore'); 1 row created. SQL> insert into christo2 values(12,'tirupur'); 1 row created. SQL> insert into christo2 values(13,'chennai'); 1 row created.
63

SQL> insert into christo2 values(14,'pollachi'); 1 row created. SQL> insert into christo2 values(15,'ooty'); 1 row created. SQL> select * from christo2; PLACE_ID BUS_STATIO ---------11 12 13 14 ---------coimbatore tirupur chennai pollachi

15 ooty SQL> insert into christo3 values(101,100,'madras','cochin',599,1000); 1 row created. SQL> insert into christo3 values(102,200,'cbe','tirupur',100,300); 1 row created. SQL> insert into christo3 values(103,300, 'ooty','bangalore',500,350); 1 row created. SQL> insert into christo3 values(104,400, 'madras','cbe',600,320); 1 row created. SQL> insert into christo3 values(105,500, 'tirupur','bangalore',700,500); 1 row created. SQL> select * from christo3;

64

ROUT_ID CAT_CODE ORGIN -------------FARE -------------------

DESTINATIO DISTANCE_KMS ---------------------

-----------------------------------------------------------101 1000 102 300 103 350 104 320 105 500 500 tirupur bangalore 700 400 madras cbe 600 300 ooty bangalore 500 200 cbe tirupur 100 100 madras cochin 599

SQL> insert into christo4 values(101,11,'monday'); 1 row created. SQL> insert into christo4 values(102,22,'tuesday'); 1 row created. SQL> insert into christo4 values(103,33,'wednesday'); 1 row created. SQL> insert into christo4 values(104,44,'thursday'); 1 row created. SQL> insert into christo4 values(105,55,'friday'); 1 row created.
65

SQL> select * from christo4; ROUTE_ID PLACE_ID DAY ---------- ---------- ---------101 102 103 104 105 11 monday 22 tuesday 33 wednesday 44 thursday 55 friday

SQL> insert into christo5 values(27,6); 1 row created. SQL> insert into christo5 values(200,67); 1 row created. SQL> insert into christo5 values(487,90); 1 row created. SQL> insert into christo5 values(499,6); 1 row created. SQL> insert into christo5 values(456,89); 1 row created. SQL> select * from christo5; TICKET_NO NO_OF_TICKET ---------- -----------27 200 487 6 67 90
66

499 456

6 890

SQL> insert into christo6 values(111,'christo','male',20,278,400); 1 row created. SQL> insert into christo6 values(200,'deepa','female',18,425,786); 1 row created. SQL> insert into christo6 values(249,'angel','female',20,278,400); 1 row created. SQL> insert into christo6 values(186,'ganesh','male',20,480,815); 1 row created. SQL> select * from christo6; TICKETNO PASSENGER_ GENDER AGE SEAT_NO AMOUNT

---------- ---------- ------ ---------- ---------- ---------111 christo 200 deepa 249 angel 186 ganesh male female female male 20 18 20 20 278 425 278 480 400 786 400 815

SQL> select * from christo3 where orgin = 'madras' and destination = 'cochin'; ROUT_ID CAT_CODE ORGIN DESTINATIO DISTANCE_KMS

---------- ---------- ---------- ---------- -----------FARE -------------------------------------------------------------------------------101 1000


67

100 madras

cochin

599

SQL> select distinct cat_code from christo3 order by cat_code desc; CAT_CODE ---------400 200 100 SQL> update christo3 set distance_kms=500 where orgin = 'madras' and destination='cbe'; 1 row updated. SQL> select * from christo3; ROUT_ID CAT_CODE ORGIN DESTINATIO DISTANCE_KMS

---------- ---------- ---------- ---------- -----------FARE ----------------------------------------------------------------101 1000 100 madras cochin 599

102 300

200 cbe

tirupur

100

103 350

300 ooty

bangalore

500

68

ROUT_ID CAT_CODE ORGIN

DESTINATIO DISTANCE_KMS

---------- ---------- ---------- ---------- -----------FARE ----------------------------------------------------------------104 320 400 madras cbe 500

105 500

500 tirupur bangalore

700

Result: Thus the above queries has been executed and verified successfully.

69

EX.NO: 3 DATE:22.07.13

QUERIES

AIM: Display the row from table6 with matching any row with table thus create a view with ticket no, origin, destination route id from table.

ALGORITHM: Step1: Start the process. Step2: All rows are displayed with sub query from the table. Step3: View the row from with place id=100; Step4: All row displayed from views. Step5: Stop the process.

70

SQL> select * from christo6 where ticket_no>any (select ticket_no from christo5); TICKET_NO PASSENGER_ GENDER AGE SEAT_NO AMOUNT

---------- ---------- ------ ---------- ---------- ---------111 christo 200 deepa 249 angel 186 ganesh male female female male 20 18 20 20 278 425 278 480 400 786 400 815

SQL> select * from christo3 where rout_id >all(select route_id from christo4 where place_id=100); ROUT_ID CAT_CODE ORGIN DESTINATIO DISTANCE_KMS

---------- ---------- ---------- ---------- -----------FARE ------------------------------------------------------------101 1000 102 300 103 350 ROUT_ID CAT_CODE ORGIN DESTINATIO DISTANCE_KMS 300 ooty bangalore 500 200 cbe tirupur 100 100 madras cochin 599

---------- ---------- ---------- ---------- -----------FARE -------------------------------------------------------------

71

104 320 105 500

400 madras

cbe

500

500 tirupur bangalore

700

SQL> create view ksg as select ticket_no, orgin, destination, rout_id from christo5, christo3; View created. SQL> select * from ksg; TICKET_NO ORGIN DESTINATIO ROUT_ID

---------- ---------- ---------- ---------27 madras 200 madras 487 madras 499 madras 456 madras 27 cbe 200 cbe 487 cbe 499 cbe 456 cbe 27 ooty cochin cochin cochin cochin cochin tirupur tirupur tirupur tirupur tirupur bangalore 101 101 101 101 101 102 102 102 102 102 103

TICKET_NO ORGIN

DESTINATIO

ROUT_ID

---------- ---------- ---------- ---------200 ooty 487 ooty bangalore bangalore 103 103
72

499 ooty 456 ooty 27 madras 200 madras 487 madras 499 madras 456 madras

bangalore bangalore cbe cbe cbe cbe cbe

103 103 104 104 104 104 104 105 105

27 tirupur bangalore 200 tirupur bangalore

TICKET_NO ORGIN

DESTINATIO

ROUT_ID

---------- ---------- ---------- ---------487 tirupur bangalore 499 tirupur bangalore 456 tirupur bangalore 105 105 105

25 rows selected.

Result: Thus the above queries has been executed and verified successfully.

73

EX.NO: 4 DATE:30.07.13

REPORT GENERATION

AIM: To generate a report from the table for the particular ticket no.

ALGORITHM: Step1: Start the process. Step2: All column names all justify into the center position. Step3: Format are generate for all columns. Step4: Compute amount for the ticket number. Step5: Stop the process.

74

SQL> ttitle center 'III BSC CS' skip 2 SQL> column ticket_no heading ticket_no justify center SQL> column passenger_name heading passenger_name justify center SQL> column gender heading gender justify center SQL> column age heading age justify center SQL> column seatno heading seatno justify center SQL> column amount heading amount justify center SQL> column ticket_no format 9999 SQL> column passenger_name format a13 SQL> column gender format a12 SQL> column age format 99 SQL> column seatno format 9999 SQL> column amount format 9999 SQL> compute sum of amount on ticket_no SQL> break on ticket_no skip2 SQL> select ticket_no, passenger_name, gender, age, seat_no, amount from christo6 order by ticket_no; III BSC CS ticket_no passenger_nam gender age SEAT_NO --278 ---------400 -----400 amount ------

--------- ------------------ -----------111 christo ********* sum male 20

75

186 ganesh ********* sum

male

20

480

815 -----815

III BSC CS ticket_no passenger_nam ------------ --------------200 ********* sum deepa gender age SEAT_NO amount

------------ --- ---------- ---------female 18 425 786 -----786

249 ********* sum

angel

female

20

278

400 -----400

Result: Thus the above queries has been executed and verified successfully.

76

EX.NO: 5 DATE:07.08.13

PL/SQL

AIM: To update erode for bus station 200 for distance in table using PL/SQL and create to insert trigger to table and display no transaction on weekends and not allowing for deleting. ALGORITHM: Step1: Start the process. Step2: Cursor was creating form table and bus station was updated as erode 50 or 1 and display. Step3: Where place id=fare was updated as200 for the table where distance was<500. Step4: Trigger was inserted into table and deleted rows are displayed allowing at deletion. Step5: Stop the process.

77

SQL> select * from christo2; PLACE_ID BUS_STATION ---------- ---------11 coimbatore 12 tirupur 13 chennai 14 pollachi 15 ooty SQL> desc christo2; Name Null? Type

----------------------------------------- -------- ---------------------------PLACE_ID BUS_STATION NOT NULL NUMBER(3) VARCHAR2(10)

SQL> declare 2 begin 3 update christo2 set bus_station='COIMBATORE' where place_id=11 or place_id=15; 4 end; 5 / PL/SQL procedure successfully completed. SQL> select * from christo2; PLACE_ID BUS_STATIO ---------- ---------11 COIMBATORE
78

12 tirupur 13 chennai 14 pollachi 15 COIMBATORE SQL> declare 2 begin 3 update christo3 4 set fare=200 where rout_id=&user_value and distance_kms<500; 5 end; 6 / Enter value for user_value: 444 old 4: set fare=200 where rout_id=&user_value and distance_kms<500; new 4: set fare=200 where rout_id=444 and distance_kms<500; PL/SQL procedure successfully completed. SQL> select * from christo3; ROUT_ID CAT_CODE ORGIN DESTINATIO DISTANCE_KMS

---------- ---------- ---------- ---------- -----------FARE -----------------------------------------------------------101 1000 102 300 103 350
79

100 madras

cochin

599

200 cbe

tirupur

100

300 ooty

bangalore

500

ROUT_ID CAT_CODE ORGIN

DESTINATIO DISTANCE_KMS

---------- ---------- ---------- ---------- -----------FARE -----------------------------------------------------------104 320 105 500 500 tirupur bangalore 700 400 madras cbe 600

SQL> create or replace trigger mbmb_tri 2 before insert on christo4 3 for each row 4 begin 5 if:new.day='saturday' or :new.day='sunday' then 6 raise_application_error(-20121,'operation not allowed'); 7 end if; 8 end; 9 / Trigger created. SQL> create or replace trigger mbmb_tri 2 before insert on christo4 3 for each row 4 begin 5 if:new.day='saturday' or :new.day='sunday' then
80

6 raise_application_error(-20121,'operation not allowed'); 7 end if; 8 end; 9 / Trigger created. SQL> insert into christo4 values(100,212,'sunday'); insert into christo4 values(100,212,'sunday') * ERROR at line 1: ORA-20121: operation not allowed ORA-06512: at "SCOTT.MBMB_TRI", line 3 ORA-04088: error during execution of trigger 'SCOTT.MBMB_TRI'

SQL> create or replace trigger deltri 2 before delete on christo4 3 for each row 4 begin 5 if deleting then 6 raise_application_error(-20022,'sorry deleting not allowed'); 7 end if; 8 end; 9 / Trigger created.

81

SQL> delete from christo4; delete from christo4 * ERROR at line 1: ORA-20022: sorry deleting not allowed ORA-06512: at "SCOTT.DELTRI", line 3 ORA-04088: error during execution of trigger 'SCOTT.DELTRI'

Result: Thus the above queries has been executed and verified successfully.

82

EX.NO: 6 DATE:03.09.13

STUDENT DATABASE MANAGEMENT SYSTEM

AIM:
To write a program to create table by using student database management system, ALGORITHM: Step1: Start the process. Step2: Design the front-end for student database management system using visual basic 6.0. Step3: Create a table in back-end for student database management system using oracle. Step4: Provide the connectivity using ADO and establish the connection. Step5: Perform operation such as insert, update and delete. Step6: Stop the process.

83

FORM DESIGN:

84

SOURCE CODE: Private Sub Command1_Click() Adodc1.Recordset.AddNew Text1.SetFocus End Sub

Private Sub Command2_Click() Adodc1.Recordset.Delete Adodc1.Refresh End Sub

Private Sub Command3_Click() Adodc1.Recordset.Update Adodc1.Refresh End Sub

Private Sub Command4_Click() End End Sub

85

OUTPUT:

RESULT: Thus the above project has been executed and verified successfully.

86

Vous aimerez peut-être aussi