database management systems lab

Upload: chandra-sekhar-d

Post on 03-Jun-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 Database Management Systems Lab

    1/57

    1

    Department of Computer Science & Engineering

    141452 DBMS LABEXP.N0:1 DATA DEFINITION LANGUAGE

    [DDL]

    AIM:To execute the DATA DEFINITION LANGUAGE (DDL) commands.

    CREATING A TABLE

    SYNTAX:

    create table (column 1 datatype 1,., column n datatype n);

    EXPLANATION:

    Create command is used to create a table in the database.

    EXAMPLE:

    SQL> create table student (VT number, name varchar (10));

    OUTPUT:Table created.

    DESC COMMAND

    SYNTAX:

    desc ;

    EXPLANATION:

    This command is used to view the structure of the table.

    EXAMPLE:

    SQL> desc student;

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    2/57

    2

    OUTPUT:NAME NULL? TYPE

    VT NUMBERNAME VARCHAR (10)

    ALTERING A TABLE

    EXPLANATION:

    The structure of the table can be changed using this command like addnew column, change the width of a datatype, change the datatype of acolumn.

    1. MODIFY

    SYNTAX:

    alter table modify (column datatype, );

    EXAMPLE:

    SQL> alter table student modify (name varchar (20));

    OUTPUT: Table altered.

    2. ADD / DROP

    SYNTAX:

    alter table add/drop (column datatype, );

    EXAMPLE:

    SQL> alter table student add (dept varchar (20));SQL> alter table student drop (addr);

    OUTPUT:

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    3/57

    3

    Table altered.

    SYNTAX:

    TRUNCATING A TABLE

    truncate table ;

    EXPLANATION:

    This command is used to delete all records stored in a table, but thestructure of the table is retained.

    EXAMPLE:

    SQL> truncate table student;

    OUTPUT:Table truncated.

    DROPPING A TABLE

    SYNTAX:

    drop table ;

    EXPLANATION:

    This command is used to remove a table from the database.

    EXAMPLE:

    SQL> drop table student;

    OUTPUT:Table dropped.

    RESULT:Thus, the data definition language commands were executed and their outputs

    were verified.

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    4/57

    4

    EXP.N0:2 DATA MANIPULATION LANGUAGE

    [DML]

    AIM:To execute the DATA MANIPULATION LANGUAGE (DML) commands.

    INSERT COMMANDS

    1. INSERT A ROW WITH VALUES FOR COLUMNS IN A TABLE.

    SYNTAX:

    insert into values (value1, value2,, value n);

    EXPLANATION:

    This insert command is used to add rows to a table in the database.

    EXAMPLE:

    SQL> insert into student values (4169, rameeze);

    OUTPUT:1 row created.

    2. INSERT A LARGE NUMBER OF ROWS.

    SYNTAX:

    insert into values (&value1, &value2,, &value n);

    EXPLANATION:

    This insert command is used to add multiple rows to a table in thedatabase.

    EXAMPLE:SQL> insert into student values (&vt, &name);

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    5/57

    5

    OUTPUT:Enter value for vt: 4169Enter value for name: rameezeOld 1: insert into student values (&vt, &name)New 1: insert into student values (4169, rameeze)

    1 row created.

    SELECT COMMANDS

    1. SELECT ALL ROWS FROM A TABLE.

    SYNTAX:

    select * from ;

    EXPLANATION:

    This select command is used to retrieve all the values stored in the table.

    EXAMPLE:SQL> select * from student;

    OUTPUT:

    VT NAME

    4169 RAMEEZE

    2. SELECT DISTINCT ROWS FROM A TABLE.

    SYNTAX:

    select from ;

    EXPLANATION:

    This select command is used to retrieve the particular field values stored inthe table.

    EXAMPLE:SQL> select name from student;

    OUTPUT:

    NAME

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    6/57

    6

    RAMEEZE

    3. SELECT USING WHERE COMMAND.

    SYNTAX:

    select from where ;

    EXPLANATION:

    This select command is used to retrieve the particular field values, storedin the table, which satisfy a required condition.

    EXAMPLE:SQL> select name from student where vt=4169;

    OUTPUT:

    NAME

    RAMEEZE

    UPDATE COMMAND

    SYNTAX:

    update set column1=expression, column 2=expression, ,column n=expression where ;

    EXPLANATION:

    This command is used to update (changing values in) one or two columnsof a row in a table. Specific rows can be updated based on some condition.

    EXAMPLE:SQL> update student set name=md rameeze where vt =4169;

    OUTPUT:

    1 row updated.

    SQL> select * from student;

    VT NAME

    4169 MD RAMEEZE

    DELETE COMMAND

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    7/57

    7

    SYNTAX:

    delete from where ;

    EXPLANATION:

    This command is used to delete a row from a table.

    EXAMPLE:SQL> delete from student where vt =4169;

    OUTPUT:1 row deleted.

    SQL> select * from student;

    no rows selected.

    TRANSACTION CONTROL LANGUAGE:

    All changes made to the database is defined as a transaction. It is logical unit of work.The transaction can made permanent to a database only they are committed. A transaction beginswith an executable SQL statement. The two transaction control commands are:

    1. COMMIT:

    1. COMMIT2. ROLLBACK

    This command is used to make all transaction changes permanent to the database.This command erases all save point and release the transaction lock.

    Syntax:

    COMMIT

    SAVEPOINT:

    It is not a command. It is only a marker. Save point are used to divide as lengthy

    transaction into smaller ones.

    Syntax:

    Savepoint id;

    2. ROLLBACK:

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    8/57

    8

    Rollback commands undo all the changes made in the current transaction.

    Syntax:a. Rollback

    b. Rollback to Save point id1;

    The first one will rollback (undo) the entire transaction and the last one will undo all changesmade after the creation of the save point id1.

    DATA CONTROL LANGUAGE:

    Data control language, the previous user with privileges commands the database object(table, view, etc) of a user cant be accessed by another user without the permission of a user. Theowner can allow other user to access his object as per his diversion the permission given by auser to another is called privilege.

    The Data Control Commands are:

    i. GRANT Privilegeii. REVOKE Privilege

    Types of Privilege:

    A permission granted to execute the various data definition command like Create Table,Create Sequence, create session are called System Privilege.

    Granting System Privilege:

    Grant Command is used to give System Privilege to an oracle user.

    Syntax:

    GRANT system privilege TO user

    Example:

    GRANT CREATE session TO anu;GRANT CREATE table TO anu;

    Object Privilege:

    An Object Privilege enables a user to execute some commands on the database object liketable view sequence etc. Some of the object privileges are

    i. Alter

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    9/57

    9

    ii. Indexiii. Insertiv. Updatev. Deletevi. Select

    vii. References

    Syntax:

    Grant object privilege [Object privilege] ON object to user [with grant option]

    Example:

    SQL> Grant Create session to student;SQL> Grant create table to student;SQL> Connect student/young;SQL> Connect system/managers;SQL> Create user staff identified by guru;SQL> Grant resource to staff;SQL> Connect staff/guru;SQL> Select * from staff;

    Staff master in a table in the user staff we first log on the staff[SQL> Connect staff/guru;]SQL> Grant select insert on staff master to student;

    Now log on to student and try the select commandSQL> Connect student/young;SQL> Select * from staff;

    In this manner you can verify the following example:-1. SQL> Grant select, update, delete on student-master to staff;2.

    Revoking the permission:

    Permission granted to a user can also be taken back by the granter. This can be done bythe REVOKE command.

    Syntax:

    Revoke object privilege [object privilege] ON object name from user name;

    Example:

    i. SQL> REVOKE SELECT, INSERT ON STUDENT_MASTER from staff;ii. SQL> REVOKE SELECT ON STUDENT_MASTER from rajan;

    RESULT:

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    10/57

    10

    Thus the given DML, DCL and TCL commands are successfully executed and the outputis verified.

    EXP.N0:3 QUERIES IN SQL

    AIM:To write and execute queries in SQL.

    1. SELECT

    Example: select name from cust;

    Output: NAMEhayesjonesblake

    2. WHERE

    Example: select city from cust where name= hayes;

    Output: CITYharrison

    3. FROM

    Example: select name, city from cust;

    Output: NAME CITYhayes harrisonjones redwoodblake downtownbritto mounthillsmith harrison

    4. RENAME

    Example: select borrower.loan_no as loan_id from borrower;

    Output: LOAN_ID1693

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    11/57

    11

    151417

    5. STRING OPERATIONS

    (a) %.

    Example: select name from cust where city like har%;

    Output: NAMEhayessmith

    (b) _.

    Example: select city from cust where name like _ _ _ _ _;

    Output: CITYharrisonredwooddowntownharrison

    6. ORDERING OF TUPLES

    Example: select * from loan order by amount asc;

    Output: LOAN NO BRANCH AMOUNT

    7. UNION

    11 roundhill 90016 perryridge 110014 downtown 1500

    15 perryridge 150017 redwood 2000

    Example: (select name from depositor) union (select name from borrower);

    Output: NAME

    adamsbrittohayesjonessmith

    8. INTERSECTION

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    12/57

    12

    Example: (select name from depositor) intersect (select name from borrower);

    Output: NAMEhayesjones

    9. AGGREGATE FUNCTIONS

    (a) AVERAGE.

    Example: select avg (balance) from account;

    Output: AVG (BALANCE)487.5

    (b) MINIMUM.

    Example: select min (balance) from account;

    Output: MIN (BALANCE)350

    (c) MAXIMUM.

    Example: select max (balance) from account;

    Output: MAX (BALANCE)700

    (d) TOTAL.

    Example: select total (balance) from account;

    Output: SUM (BALANCE)1950

    (e) COUNT.

    Example: select count (balance) from account;

    Output: COUNT (BALANCE)4

    10. NESTED QUERIES

    Example: select name from depositor where depositor.name in (select name from

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    13/57

    13

    cust);

    Output: NAMEhayesjones

    RESULT:Thus, the queries in SQL were executed and the outputs were verified.

    Ex.No:4 VIEWS

    AIM:To study the Simple View and Complex View and to execute them.

    Views

    (i) Logically represents subsets of data from one or more tables.(ii) You can present logical subsets or combinations of data by creating views of tables. A viewis a logical table based on a table or another view. A view contains no data of its own but is likea window through which data from tables can be viewed or changed. The tables on which a viewis based are called base tables. The view is stored as a SELECT statement in the data dictionary.

    Why Use Views? To restrict data access To make complex queries easy To provide data independence To present different views of the same data.

    Advantages of Views Views restrict access to the data because the view can display selective columns from the table. Views can be used to make simple queries to retrieve the results of complicated queries. Forexample, views can be used to query information from multiple tables without the user knowinghow to write a join statement. Views provide data independence for ad hoc users and application programs. One view can beused to retrieve data from several tables. Views provide groups of users access to data according to their particular criteria.

    Simple Views versus Complex ViewsThere are two classifications for views: simple and complex. The basic difference is related tothe DML (INSERT, UPDATE, and DELETE) operations. A simple view is one that: Derives data from only one table Contains no functions or groups of data Can perform DML operations through the view A complex view is one that: Derives data from many tables

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    14/57

    14

    Contains functions or groups of data Does not always allow DML operations through the view

    Creating a View

    You embed a subquery within the CREATE VIEWstatement.

    Syntax:CREATE [OR REPLACE] [FORCE|NOFORCE] VIEW view[(alias[, alias]...)] AS subquery[WITH CHECK OPTION [CONSTRAINT constraint]][WITH READ ONLY [CONSTRAINT constraint]];

    The subquery can contain complex SELECT

    Example: Create a view, EMPVU80, that contains details of

    employees in department 80.

    CREATE VIEW empvu80AS SELECT employee_id, last_name, salaryFROM employeesWHERE department_id = 80;View created.

    Describe the structure of the view by using the iSQL*Plus DESCRIBE command.

    Example:DESCRIBE empvu80

    Assigning Names to ColumnsWe Can Assign names for the various colmns in the view.

    * Create a view by using column aliases in the

    subquery.

    CREATE VIEW salvu50AS SELECT employee_id ID_NUMBER, last_name NAME,salary*12 ANN_SALARYFROM employeesWHERE department_id = 50;View created.(or)CREATE VIEW salvu50(ID_NUMBER,NAME,ANN_SALARY)AS SELECT employee_id , last_name ,

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    15/57

    15

    salary*12FROM employeesWHERE department_id = 50;View created.

    Select the columns from this view by the given alias names.

    Retrieving Data from a View

    SELECT * FROM salvu50;

    Modifying a View

    Modify the EMPVU80 view by using CREATE OR REPLACE VIEW clause. Add an alias foreach column name. Column aliases in the CREATE VIEW clause are listed in the same order as the columns in thesubquery.

    CREATE OR REPLACE VIEW empvu80

    (id_number, name, sal, department_id)AS SELECT employee_id, first_name || || last_name,salary, department_idFROM employeesWHERE department_id = 80;View created.

    Creating a Complex View

    Create a complex view that contains group functions to display values from two tables.

    CREATE VIEW dept_sum_vu(name, minsal, maxsal, avgsal)AS SELECT d.department_name, MIN(e.salary),MAX(e.salary),AVG(e.salary)FROM employees e, departments dWHERE e.department_id = d.department_idGROUP BY d.department_name;View Created;

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    16/57

    16

    Creating a Complex View

    The example on the slide creates a complex view of department names, minimum salaries,

    maximum salaries, and average salaries by department. Note that alternative names have beenspecified for the view. This is a requirement if any column of the view is derived from a functionor an expression. You can view the structure of the view by using the iSQL*Plus DESCRIBEcommand. Display the contents of the view by issuing a SELECT statement.

    SELECT *FROM dept_sum_vu;

    Removing a View

    You can remove a view without losing data because a view is based on underlying tables in thedatabase.

    Syntax:DROP VIEW view;

    Example:DROP VIEW empvu80;View dropped.

    RESULT:

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    17/57

    17

    Thus, the Simple view and Complex view were executed and the outputs were verified.

    EXP.N0:5 HIGH LEVEL PROGRAMMING LANGUAGE EXTENSIONS

    FUNCTIONS AND PROCEDURES

    AIM:To implement FUNCTIONS AND PROCEDURES using STRUCTURED

    QUERY LANGUAGE.

    ALGORITHM:

    1. Create the function using function name.2. Declare the variables to be used.3. Begin the function.4. Specify the operations.5. Return the value to the variable declared.6. End.7. Procedure does not return value, but helps to call a function.

    PROGRAM (a):

    SQL> create or replace function F1 (n number)return number isk number;begink: = n*100;return k;end;/

    OUTPUT:function created.

    SQL> select F1(3) from dual;

    F1 (3)300

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    18/57

    18

    PROGRAM (b):

    SQL> create or replace function F2 (a number)return char iso varchar 2(25):= The number is odd;e varchar 2(25):= The number is even;r number;beginr: = mod (a, 2);if r=0 then return e;elsereturn o;endif;end;

    /

    OUTPUT:function created.

    SQL> select F2 (9) from dual;

    F2 (9)The number is odd.

    PROGRAM (c):

    SQL> select * from emp;

    6 rowsselected.

    15NO NAME

    SACHINEMPSAL9000 11

    DEPT

    16 SAURAV 9000 1117 RAHUL 9000 0118 YUVRAJ 7500 1119 DHONI 6000 1020 GAUTAM 5000 10

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    19/57

    19

    SQL>create or replace function F3 (sal number, dept number)return number isminsal number;maxsal number ;begin

    select MIN (empsal), MAX (empsal) into minsal, maxsalfrom emp where dept= dept1;if ((sal>= minsal) and (sal set serveroutput on;

    SQL> declarea number;begina: = F3 (&sal, &dept);if a=0 thendbms_output.put_line (Salary out of range.);elsedbms_output.put_line (Salary is in range and is||a);endif;end;/

    OUTPUT:Enter the value for sal: 9000Enter the value for dept.: 01old 4 : a: = f3(&sal, &dept);new 4: a:= f3 (9000, 01);

    Salary is in range and is 9000.

    PL/SQL Procedure is successfully completed.

    RESULT:Thus, the FUNCTIONS AND PROCEDURES were executed using SQL

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    20/57

    20

    and the outputs were verified.

    Ex.No:6 FRONT END TOOLS

    Aim:To study about the various front end tools to design forms and reports.

    Examples Front End Tools:

    Visual Basic

    Visual C++

    Java

    PHP

    HTML

    1. MICROSOFT VISUAL BASIC:

    Visual Basic (VB) is the third-generation event-driven programming language andintegrated development environment (IDE) from Microsoft for its COM programming model.Visual Basic is relatively easy to learn and use.

    Visual Basic was derived from BASIC and enables the rapid application development (RAD) ofgraphical user interface (GUI) applications, access to databases using Data Access Objects,Remote Data Objects, or ActiveX Data Objects, and creation of ActiveX controls and objects.Scripting languages such as VBA and VBScript are syntactically similar to Visual Basic, butperform differently.

    A programmer can put together an application using the components provided with Visual Basic

    itself. Programs written in Visual Basic can also use the Windows API, but doing so requiresexternal function declarations.

    The final release was version 6 in 1998. Microsoft's extended support ended in March 2008 andthe designated successor was Visual Basic .NET (now known simply as Visual Basic).

    Language features

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    21/57

    21

    Like the BASIC programming language, Visual Basic was designed to be easily learned andused by beginner programmers. The language not only allows programmers to create simple GUIapplications, but can also develop complex applications. Programming in VB is a combination ofvisually arranging components or controls on a form, specifying attributes and actions of thosecomponents, and writing additional lines of code for more functionality. Since default attributes

    and actions are defined for the components, a simple program can be created without theprogrammer having to write many lines of code. Performance problems were experienced byearlier versions, but with faster computers and native code compilation this has become less ofan issue.

    Although programs can be compiled into native code executables from version 5 onwards, theystill require the presence of runtime libraries of approximately 1 MB in size. This runtime isincluded by default in Windows 2000 and later, but for earlier versions of Windows like95/98/NT it must be distributed together with the executable.

    Forms are created using drag-and-drop techniques. A tool is used to place controls (e.g., textboxes, buttons, etc.) on the form (window). Controls have attributes and event handlersassociated with them. Default values are provided when the control is created, but may bechanged by the programmer. Many attribute values can be modified during run time based onuser actions or changes in the environment, providing a dynamic application. For example, codecan be inserted into the form resize event handler to reposition a control so that it remainscentered on the form, expands to fill up the form, etc. By inserting code into the event handlerfor a key press in a text box, the program can automatically translate the case of the text beingentered, or even prevent certain characters from being inserted.

    Visual Basic can create executables (EXE files), ActiveX controls, or DLL files, but is primarilyused to develop Windows applications and to interface database systems. Dialog boxes with lessfunctionality can be used to provide pop-up capabilities. Controls provide the basic functionalityof the application, while programmers can insert additional logic within the appropriate eventhandlers. For example, a drop-down combination box will automatically display its list and allowthe user to select any element. An event handler is called when an item is selected, which canthen execute additional code created by the programmer to perform some action based on whichelement was selected, such as populating a related list.

    Alternatively, a Visual Basic component can have no user interface, and instead provide ActiveXobjects to other programs via Component Object Model (COM). This allows for server-sideprocessing or an add-in module.

    The language is garbage collected using reference counting, has a large library of utility objects,and has basic object oriented support. Since the more common components are included in thedefault project template, the programmer seldom needs to specify additional libraries. Unlikemany other programming languages, Visual Basic is generally not case sensitive, although it willtransform keywords into a standard case configuration and force the case of variable names toconform to the case of the entry within the symbol table. String comparisons are case sensitiveby default, but can be made case insensitive if so desired.

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    22/57

    22

    The Visual Basic compiler is shared with other Visual Studio languages (C, C++), butrestrictions in the IDE do not allow the creation of some targets (Windows model DLLs) andthreading models.

    Characteristics

    Visual Basic has the following traits which differ from C-derived languages:

    Multiple assignment available in C language is not possible. A = B = C does not implythat the values of A, B and C are equal. The Boolean result of "Is B = C?" is stored in A. Theresult stored in A would therefore be either false or true.

    Boolean constant True has numeric value 1.[4] This is because the Boolean data type is

    stored as a 16-bit signed integer. In this construct 1 evaluates to 16 binary 1s (the Booleanvalue True), and 0 as 16 0s (the Boolean value False). This is apparent when performing aNot operation on a 16 bit signed integer value 0 which will return the integer value 1, inother words True = Not False. This inherent functionality becomes especially useful whenperforming logical operations on the individual bits of an integer such as AND, OR, XORand Not.

    [5]This definition of True is also consistent with BASIC since the early 1970s

    Microsoft BASIC implementation and is also related to the characteristics of CPUinstructions at the time.

    Logical and bitwise operators are unified. This is unlike some C-derived languages (suchas Perl), which have separate logical and bitwise operators. This again is a traditional featureof BASIC.

    Variable array base. Arrays are declared by specifying the upper and lower bounds in away similar to Pascal and FORTRAN. It is also possible to use the Option Base statement toset the default lower bound. Use of the Option Base statement can lead to confusion whenreading Visual Basic code and is best avoided by always explicitly specifying the lowerbound of the array. This lower bound is not limited to 0 or 1, because it can also be set bydeclaration. In this way, both the lower and upper bounds are programmable. In moresubscript-limited languages, the lower bound of the array is not variable. This uncommontrait does exist in Visual Basic .NET but not in VBScript.

    2. MICROSOFT VISUAL C++

    Microsoft Visual C++ (often abbreviated as MSVC or VC++) is a commercial (freeversion available), integrated development environment (IDE) product from Microsoft for the C,C++, and C++/CLI programming languages. It has tools for developing and debugging C++code, especially code written for the Microsoft Windows API, the DirectX API, and theMicrosoft .NET Framework.

    History

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    23/57

    23

    The predecessor to Visual C++ was calledMicrosoft C/C++. There was also aMicrosoft QuickC2.5 and aMicrosoft QuickC for Windows 1.0.

    16-bit versions

    Microsoft C 1.0, based on Lattice C, was Microsoft's first C product in 1983. It was notK&R C. C 2.0 added large model support. C 3.0 was the first version developed inside Microsoft. It was extremely compatible with

    K&R and the later ANSI standard. It was being used inside Microsoft (for Windows andXenix development) in early 1984. It shipped as a product in 1985.

    C 4.0 added optimizations and CodeView, a source level debugger. C 5.0 added loop optimizations and Huge Model (arrays bigger than 64k) support.

    Microsoft FORTRAN and the first 32 bit compiler for 80386 were also part of this project. C 6.0 released in 1989. It added global flow analysis, a source browser, and a new

    debugger, and included an optional C++ front end.

    C/C++ 7.0 was released in 1992. It added built-in support for C++ and MFC 1.0.

    [2]

    Visual C++ 1.0, which included MFC 2.0, was the first version of Visual C++, released

    in February 1993. It was Cfront 2.1 compliant[3]

    and available in two editions:[4]

    o Standard replaced QuickC for Windows.o Professional replaced C/C++ 7.0. Included the ability to build both DOS and

    Windows applications, an optimizing compiler, a source profiler, and the Windows 3.1 SDK.

    [3]The Phar Lap 286 DOS Extender Lite was also included.

    [5]

    Visual C++ 1.5 was released in December 1993, included MFC 2.5, and added OLE 2.0and ODBC support to MFC.

    [6]It was the first version of Visual C++ that came only on CD-

    ROM.o Visual C++ 1.51 and 1.52 were available as part of a subscription service.o

    Visual C++ 1.52b is similar to 1.52, but does not include the ControlDevelopment Kit.o Visual C++ 1.52c was a patched version of 1.5. It is the last, and arguably most

    popular, development platform for Microsoft Windows 3.x. It is available throughMicrosoft Developer Network.

    32-bit versions

    Visual C++ 1.0 (original name: Visual C++ 32-bit Edition) was the first version for 32-bit development. Although released when 16-bit 1.5 was available, it did not includesupport for OLE2 and ODBC. It was also available in a bundle called Visual C++ 16/32-

    bit Suite, which included Visual C++ 1.5. Visual C++ 2.0, which included MFC 3.0, was the first version to be 32-bit only. Inmany ways, this version was ahead of its time, since Windows 95, then codenamed"Chicago", was not yet released, and Windows NT had only a small market share. As aresult, this release was almost a "lost generation". Microsoft included and updated VisualC++ 1.5 as part of the 2.x releases up to 2.1, which included Visual C++ 1.52, and both16-bit and 32-bit version of the Control Development Kit (CDK) were included. VisualC++ 2.x also supported Win32s development. It is available through Microsoft Developer

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    24/57

    24

    Network. There was a Visual C++ 2.0 RISC Edition for MIPS and Alpha processors, aswell as a cross-platform edition for the Macintosh (68000 instruction set).

    o Visual C++ 2.1 and 2.2 were updates for 2.0 available through subscription. Visual C++ 4.0, which included MFC 4.0, was designed for Windows 95 and Windows

    NT. To allow support of legacy (Windows 3.x/DOS) projects, 4.0 came bundled with the

    Visual C++ 1.52 installation CD. Updates available through subscription included VisualC++ 4.1, which came with the Microsoft Game SDK (later released separately as theDirectX SDK), and Visual C++ 4.2. Version number 3.0 was skipped to achieve versionnumber parity between Visual C++ 4.0 and MFC 4.0.

    [9]

    Visual C++ 4.2 did not support Windows 3.x (Win32s) development.[10] This was thefinal version with a cross-platform edition for the Macintosh available and it differedfrom the 2.x version in that it also allowed compilation for the PowerPC instruction set.

    Visual C++ 5.0, which included MFC 4.21, was a major upgrade from 4.2. [11] Availablein four editions:

    o Learningo Professionalo

    Enterpriseo RISC

    Visual C++ 6.0 (commonly known as VC6), which included MFC 6.0, was released in1998.[16] The release was somewhat controversial since it did not include an expectedupdate to MFC. Visual C++ 6.0 is still quite popular and often used to maintain legacyprojects. There are, however, issues with this version under Windows XP, especiallyunder the debugging mode (for example, the values of static variables do not display).The debugging issues can be solved with a patch called the "Visual C++ 6.0 ProcessorPack".

    Visual C++ .NET 2002 (known also as Visual C++ 7.0), which included MFC 7.0, wasreleased in 2002 with support for link time code generation and debugging runtimechecks, .NET 1.0, and Visual C# and Managed C++. The new user interface used manyof the hot keys and conventions of Visual Basic, which accounted for some of itsunpopularity among C++ developers

    Visual C++ .NET 2003 (known also as Visual C++ 7.1), which included MFC 7.1, wasreleased in 2003 along with.NET 1.1 and was a major upgrade to Visual C++ .NET 2002.It was considered a patch to Visual C++ .NET 2002. Accordingly, the English languageupgrade version of Visual Studio .NET 2003 shipped for minimal cost to owners of theEnglish language version of Visual Studio .NET 2002. This was the last version tosupport Windows 95 and NT 4.0 as a target.

    eMbedded Visual C++ in various versions was used to develop for some versions of theWindows CE operating system. Initially it replaced a development environmentconsisting of tools added onto Visual C++ 6.0. eMbedded Visual C++ was replaced as aseparate development environment by Microsoft Visual Studio 2005.

    Visual C++ 2005 (known also as Visual C++ 8.0), which included MFC 8.0, wasreleased in November 2005. This version supports .NET 2.0 and dropped Managed C++for C++/CLI. Managed C++ for CLI is still available via compiler options though. It alsointroduced OpenMP. With Visual C++ 2005, Microsoft also introduced Team FoundationServer. Visual C++ 8.0 has problems compiling MFC AppWizard projects that werecreated using Visual Studio 6.0, so maintenance of legacy projects can be continued with

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    25/57

    25

    the original IDE if rewriting was not feasible. Visual C++ 2005 is the last version to beable to target Windows 98 and Windows Me.

    SP1 version also available in Microsoft Windows SDK Update for Windows Vista.Version number: 14.00.50727.762

    Visual C++ 2008 (known also as Visual C++ 9.0) was released in November 2007. This

    version supports .NET 3.5. Managed C++ for CLI is still available via compiler options.By default, all applications compiled against the Visual C++ 2008 Runtimes (static anddynamic linking) will only work under Windows 2000 and later. A feature pack releasedfor VC9, later included into SP1, added support for C++ TR1 library extensions.

    Visual C++ 2010 (known also as Visual C++ 10.0) was released on April 12, 2010, andit is currently the latest stable release. It uses a SQL Server Compact database to storeinformation about the source code, including IntelliSense information, for betterIntelliSense and code-completion support.[22] (However, Visual C++ 2010 does notsupport Intellisense for C++/CLI.[23]) This version adds a modern C++ parallel computinglibrary called the Parallel Patterns Library, partial support for C++0x, significantlyimproved IntelliSense, and performance improvements to both the compiler andgenerated code.[24] This version is built around .NET 4.0, but supports compiling tomachine code. The partial C++0x support mainly consists of six compiler features[25]

    (lambdas, rvalue references, auto, decltype, static_assert, nullptr), and some libraryfeatures (e.g. moving the TR1 components from std::tr1 namespace directly to stdnamespace). Variadic templates were also considered, but delayed until some futureversion due to lower priority which stemmed from the fact that unlike other costly-to-implement features (lambda, rvalue references), this one would benefit only a minority oflibrary writers than the majority of compiler end users. [26] By default, all applicationscompiled against the Visual C++ 2010 Runtimes will only work under Windows XP SP2and later.

    o Beta 2 version number: 16.00.21003.01 (this is the version of compiler; the IDEitself has version number 16.00.21006.01)[27]

    o RC version number: 16.00.30128.01o RTM version, also available in Windows SDK for Windows 7 and .NET

    Framework 4 (WinSdk v7.1).[28] Version number: 16.00.30319.01o SP1 version, also available in KB2519277 update to Windows SDK v7.1:

    16.00.40219.01

    64-bit versions

    Visual Studio 2005 Standard and Professional editions have x86-64 compiler support,and Visual Studio 2008 Team Suite supports both x86-64 and IA-64. Prior to Visual C++ 2005,the Platform SDK was the only way for programmers to develop 64-bit Windows applications.The SDK included both a compiler and a Visual C++ 6.0 library for the IA64-target.Programmers who wanted the 64-bit versions of the Visual C++ .NET 2003 libraries (which areno longer available) had to contact libs7164microsoft.com.

    3. JAVA

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    26/57

    26

    Java is a programming language originally developed by James Gosling at SunMicrosystems (now part of Oracle Corporation) and released in 1995 as a core component of SunMicrosystems' Java platform. The language derives much of its syntax from C and C++ but has asimpler object model and fewer low-level facilities. Java applications are typically compiled tobyte code (class file) that can run on any Java Virtual Machine (JVM) regardless of computer

    architecture. Java is a general-purpose, concurrent, class-based, object-oriented language that isspecifically designed to have as few implementation dependencies as possible. It is intended tolet application developers "write once, run anywhere." Java is currently one of the most popularprogramming languages in use, particularly for client-server web applications.

    [9][10]

    The original and reference implementation Java compilers, virtual machines, and class librarieswere developed by Sun from 1995. As of May 2007, in compliance with the specifications of theJava Community Process, Sun relicensed most of its Java technologies under the GNU GeneralPublic License. Others have also developed alternative implementations of these Suntechnologies, such as the GNU Compiler for Java and GNU Class path.

    Principles

    There were five primary goals in the creation of the Java language:

    1. It should be "simple, object-oriented and familiar"2. It should be "robust and secure"3. It should be "architecture-neutral and portable"4. It should execute with "high performance"5. It should be "interpreted, threaded, and dynamic"

    Versions

    Major release versions of Java, along with their release dates:

    JDK 1.0 (January 23, 1996) JDK 1.1 (February 19, 1997) J2SE 1.2 (December 8, 1998) J2SE 1.3 (May 8, 2000) J2SE 1.4 (February 6, 2002) J2SE 5.0 (September 30, 2004) Java SE 6 (December 11, 2006) Java SE 7 (July 28, 2011)

    Features of Java

    Java Platform

    One characteristic of Java is portability, which means that computer programs written inthe Java language must run similarly on any hardware/operating-system platform. This isachieved by compiling the Java language code to an intermediate representation called Java byte

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    27/57

    27

    code, instead of directly to platform-specific machine code. Java byte code instructions areanalogous to machine code, but are intended to be interpreted by a virtual machine (VM) writtenspecifically for the host hardware. End-users commonly use a Java Runtime Environment (JRE)installed on their own machine for standalone Java applications, or in a Web browser for Javaapplets.

    Standardized libraries provide a generic way to access host-specific features such as graphics,threading, and networking.

    A major benefit of using byte code is porting. However, the overhead of interpretation meansthat interpreted programs almost always run more slowly than programs compiled to nativeexecutables would. Just-in-Time compilers were introduced from early stages that compile bytecodes to machine code during runtime.

    Performance

    Programs written in Java have a reputation for being slower and requiring more memory thanthose written in C.[26] However, Java programs' execution speed improved significantly with theintroduction of Just-in-time compilation in 1997/1998 for Java 1.1, the addition of languagefeatures supporting better code analysis (such as inner classes, String Buffer class, optionalassertions, etc.), and optimizations in the Java Virtual Machine itself, such as Hotspot becoming

    the default for Sun's JVM in 2000. Currently,

    Java 2.0 code has approximately half theperformance of C code.

    Automaticmemory management

    Java uses an automatic garbage collector to manage memory in the object lifecycle. The

    programmer determines when objects are created, and the Java runtime is responsible forrecovering the memory once objects are no longer in use. Once no references to an objectremain, the unreachable memory becomes eligible to be freed automatically by the garbagecollector. Something similar to a memory leak may still occur if a programmer's code holds areference to an object that is no longer needed, typically when objects that are no longer neededare stored in containers that are still in use. If methods for a nonexistent object are called, a "nullpointer exception" is thrown.

    4.HTML

    HTML is a language for describing web pages.

    HTML stands for Hyper Text Markup Language

    HTML isnot a programming language, it isa markup language

    A markup language isa set of markup tags

    HTML uses markup tags to describeweb pages

    HTML Tags

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    28/57

    28

    HTML markup tags are usually called HTML tags

    HTML tags are keywords surrounded by angle brackets like

    HTML tags normallycome in pairs like and

    The first tag in a pair isthe start tag, the second tag isthe end tag

    Start and end tags are alsocalledopening tags and closing tags

    HTML Documents = Web Pages

    HTML documents describe web pages

    HTML documents contain HTML tags and plaintext

    HTML documents are alsocalled web pages

    The purpose of a web browser (like Internet Explorer or Firefox) is to read HTML documents and display them as web pages.The browser does not display the HTML tags, but uses the tags to interpret the content of the page:

    Editing HTML

    HTML can be written and edited using many different editors like Dreamweaver and Visual Studio.

    However, in this tutorial we use a plain text editor (like Notepad) to edit HTML. We believe using a plain text editor is the bestway to learn HTML.

    .HTM or .HTML File Extension?

    When you save an HTML file, you can use either the .htm or the .html file extension. There is no difference, it is entirely up toyou.

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    29/57

    29

    Result:Thus the front-end languages like VB, VC++, Java, and HTML are studied.

    Ex. no: 7 FORMS- PAYROLL PROCESSING SYSTEMS

    AIM:

    To implement the operations of PAYROLL PROCESSING SYSTEM using the visual basicas front end and oracle as back end to design a forms..

    PROCEDURE:

    1. Collect the details of how the program is expected by the user and also the atmosphere in which it isgoing to work.

    2. Collect the user requirement. Develop a sketch of the program about how it is going to appearin its final design.

    3. Implement the various diagram carefully, based on which the entire project design is going tobe developed.

    4. Assign the values as required by the program control settings.

    5. In the component diagram, using the update code command we generate the code for therequired program.

    6. Thus the program is implemented successfully.

    SQL TABLE:

    SQL>CREATE TABLE_DETAIL(EMPID NUMBER(5) CONSTRAINT CON PRIMARYKEY,EMPNAME VARCHAR2(15), DESIGNATION VARCHAR2(20), DEPARTMENTVARCHAR2(20), ADDRESS VARCHAR(20), BASICPAY NUMBER(10,2), PFNUMBER(10,2) HRA NUMBER(10,2),INTAX NUMBER(10,2),TOTDEDNUMBER(10,2),GROSSALRY NUMBER(10,2), NETPAY NUMBER(10,2));

    Table created.

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    30/57

    30

    CODING:

    FORM 1:

    Dim db As DatabaseDim rs As RecordsetDim PF As IntegerDim HRA As IntegerDim DA As IntegerDim GROSSPAY As IntegerDim NETPAY As IntegerDim TOTDED As IntegerDim TAX As Integer

    Private sub cmdexit_Click()Unload MeEnd sub

    Private sub cmdfirst_Click()rs.MoveFirsttxteno.Text=rs(0)txtename.Text=rs(1)txtdes.Text=rs(DESINATION)txtdept.Text=rs(DEPARTMENT)txtbasic.Text=rs(BASICPAY)End sub

    Private sub cmdlast_Click()rs.MoveLasttxteno.Text=rs(0)txtename.Text=rs(1)txtdes.Text=rs(DESINATION)txtdept.Text=rs(DEPARTMENT)txtbasic.Text=rs(BASICPAY)End sub

    Private sub cmdnew_Click()txteno.Text=txtename.Text=txtdes.Text=

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    31/57

    31

    txtdept.Text=txtbasic.Text=rs.AddNewtxteno.SetFocusEnd sub

    Private sub cmdnext_Click()rs.MoveNextIf rs.EOF ThenMsgBoxRecord pointer is in the last recordrs.MoveFirst Elsetxteno.Text=rs(0)txtename.Text=rs(1)txtdes.Text=rs(DESINATION)txtdept.Text=rs(DEPARTMENT)txtbasic.Text=rs(BASICPAY)End IfEnd sub

    Private sub cmdpayroll_Click()Form2.ShowEnd sub

    Private sub cmdprev_Click()rs.MovePreviousIf Not rs.BOf Thentxteno.Text=rs(0)txtename.Text=rs(1)txtdes.Text=rs(DESINATION)txtdept.Text=rs(DEPARTMENT)txtbasic.Text=rs(BASICPAY)ElseMsgBoxRecord pointer is in the first recordEnd IfEnd sub

    Private sub cmdsave_Click()If (Val(txtbasic.Text)=5000) And Val(txtbasic.Text)

  • 8/12/2019 Database Management Systems Lab

    32/57

    32

    HRA=Val(txtbasic.Text) *0.15DA=Val(txtbasic.Text) *0.4MA=200PF=700TAX=Val(txtbasic.Text) *0.15

    End IfIf(Val(txtbasic.Text)>=8000) ThenHRA=Val(txtbasic.Text) *0.2DA=Val(txtbasic.Text) *0.5MA=300PF=800TAX=Val(txtbasic.Text) *0.2End IfGROSSPAY= Val(txtbasic.Text)+HRA+DA+MANETPAY= GROSSPAY-(PF+TAX)rs.AddNewrs(0)= Val(txteno.Text)rs(1)= Trim(txtename.Text)rs(2)= Trim(txtdes.Text)rs(3)= Trim(txtdept.Text)rs(4)= Val(txtbasic.Text)rs(5)= DArs(6)= HRArs(7)= PFrs(8)= MArs(9)= GROSSPAYrs(10)= NETPAYrs(11)= TAXrs.UpdateMsgBoxRecord updated successfullytxteno.Text=txtename.Text=txtdes.Text=txtdept.Text=txtbasic.Text=End sub

    Private sub Form_LoadSet db = OpenDatabase(E_DETAIL,False,Fasle,odbc;uidvt4193;pwd=vt4193)Set rs =db.OpenRecordset(select*from E_DETAIL,dbOpenDynaset)MsgBoxSuccessfully connected with the Database,vbInformation,SucessfulEnd sub

    FORM2:

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    33/57

    33

    Dim db As DatabaseDim rs As Recordset

    Private sub cmdexit_Click()

    Load Form1Unload MeEnd sub

    Private sub cmdnext_Click()If(Combo1.ListIndex -1)>=0 ThenCombo1.ListIndex = Combo1.ListIndex -1displayElseMsgBox This is the first recordEnd IfEnd sub

    Private sub cmdprev_Click()

    If(Combo1.ListIndex +1)>=0 ThenCombo1.ListIndex = Combo1.ListIndex +1displayElseMsgBox This is the last recordEnd IfEnd sub

    Private sub Form_Load()Set db = OpenDatabase(E_DETAIL,False,Fasle,odbc;uidvt4202;pwd=vt4202)Set rs =db.OpenRecordset(select*from E_DETAIL order by EMPID)rs.MoveFirstCombo1.ClearDo While Not rs.EOFCombo1.AddItem rs(0)rs.MoveNextLoopCombo1.ListIndex=0End subSub display()txtename.Text=rs(1)txtdes.Text=rs(2)txtdept.Text=rs(3)txtbasic.Text=rs(4)txtda.Text=rs(5)txthra.Text=rs(6)

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    34/57

    34

    txtma.Text=rs(7)txtpf.Text=rs(8)txttax.Text=rs(9)txtgross.Text=rs(10)txtnetpay.Text=rs(11)

    End sub

    Private sub combo1_Click()rs.MoveFirstrs.FindFirst(EMPID=& val(Combo1.Text))displayEnd sub

    Form 1:

    Form 2:

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    35/57

    35

    RESULT:Thus, the payroll processing system using VB was implemented.

    EXP.N0:8 TRIGGERS

    AIM:To create TRIGGERS on the database using SQL.

    ALGORITHM:

    Begin by creating the trigger, specifying the trigger name.

    Specify whether the operation is delete/insert on rows or every statement.

    Declare the variables.

    Assign the new variables to those in tables.

    Specify the operation to be performed in the trigger.

    End.

    PROGRAM (a):

    INPUT:EMPLOY

    EMPNO SALARY10 90011 100012 1200

    SALDET

    EMPNO DEPT TOTAL10 11 900

    SQL> create trigger tripletafter update of salary on employ for each row

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    36/57

    36

    OUTPUT:

    beginupdate saldet set total = total+1500 whereempno =:new.empno;end;

    /

    trigger created.

    SQL> update employ set salary=1000 where empno=10;

    1 row updated.

    EMPLOY

    EMPNO SALARY10 100011 100012 1200

    SALDET

    EMPNO DEPT TOTAL10 11 2400

    PROGRAM (b):

    SQL> create or replace trigger secondbefore update on employ for each rowbeginif :new.sal>1000 or :new.dept =10;then raise_application_error (-20001,You are not allowed to insert.);end if;end;

    /

    OUTPUT:trigger created.

    SQL> update employ set salary =1200 where dept =10;

    Error at line 1:ORA -20001: You are not allowed to insert.

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    37/57

    37

    PROGRAM (c):

    INPUT:STUDENT

    VT NAME MARK1 MARK24170 Raja 60 73

    SQL>create or replace trigger firstbefore update on student for each rowdeclarem1 number(10);m2 number(10);beginm1:=:new.mark1;m2:=:new.mark2;if m1> m2 then raise_application_error (-20001,mark1 should be less

    than mark2);end if;end;

    /

    OUTPUT:trigger created.

    SQL> update student set mark1 =80 where VT=4170;

    Error at line 1:ORA -20001: mark1 should be less than mark2.

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    38/57

    38

    RESULT:

    Thus, the TRIGGERS were executed using SQL and the outputs were verified.Ex.No:9 MENU DESIGN

    Aim:

    To implement the operation of a menu design using the vc++ as a front end and oracle as

    bank end.

    ALGORITHM

    Step 1: Collect the details of how the program is expected from the user and develop the

    front end using Visual C++.

    Step 2: Collect the user requirements. Develop the sketch on the program.

    Step 3: Implement the various diagrams carefully, based on which the entire project design

    is going to be developed.

    Step 4: Thus the program is implemented successfully.

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    39/57

    39

    Program:

    // ex14aView.cpp : implementation of the CEx14aView class//

    #include "stdafx.h"#include "ex14a.h"

    #include "ex14aDoc.h"#include "ex14aView.h"

    #ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = FILE ;#endif

    /////////////////////////////////////////////////////////////////////////////// CEx14aView

    IMPLEMENT_DYNCREATE(CEx14aView, CView)

    BEGIN_MESSAGE_MAP(CEx14aView, CView)//{{AFX_MSG_MAP(CEx14aView) ON_COMMAND(ID_DRAW_CIRCLE,OnDrawCircle) ON_UPDATE_COMMAND_UI(ID_DRAW_CIRCLE,OnUpdateDrawCircle) ON_COMMAND(ID_DRAW_PATTERN,OnDrawPattern) ON_UPDATE_COMMAND_UI(ID_DRAW_PATTERN,OnUpdateDrawPattern) ON_COMMAND(ID_DRAW_SQUARE, OnDrawSquare)ON_UPDATE_COMMAND_UI(ID_DRAW_SQUARE, OnUpdateDrawSquare)//}}AFX_MSG_MAP

    END_MESSAGE_MAP()

    /////////////////////////////////////////////////////////////////////////////// CEx14aView construction/destruction

    CEx14aView::CEx14aView() : m_rect(0, 0, 100, 100){

    m_bCircle = TRUE;m_bPattern = FALSE;

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    40/57

    40

    }

    CEx14aView::~CEx14aView(){

    }

    BOOL CEx14aView::PreCreateWindow(CREATESTRUCT& cs){

    // TODO: Modify the Window class or styles here by modifying// the CREATESTRUCT cs

    return CView::PreCreateWindow(cs);}

    /////////////////////////////////////////////////////////////////////////////// CEx14aView drawing

    void CEx14aView::OnDraw(CDC* pDC){

    CBrush brush(HS_BDIAGONAL, 0L); // brush with diagonal pattern

    if (m_bPattern) {pDC->SelectObject(&brush);

    }else {

    pDC->SelectStockObject(WHITE_BRUSH);}if (m_bCircle) {

    pDC->Ellipse(m_rect);}else {

    pDC->Rectangle(m_rect);}pDC->SelectStockObject(WHITE_BRUSH);// Deselects brush

    // if selected}

    /////////////////////////////////////////////////////////////////////////////// CEx14aView diagnostics

    #ifdef _DEBUGvoid CEx14aView::AssertValid() const{

    CView::AssertValid();}

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    41/57

    41

    void CEx14aView::Dump(CDumpContext& dc) const{

    CView::Dump(dc);}

    CEx14aDoc* CEx14aView::GetDocument() // non-debug version is inline{

    ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx14aDoc)));return (CEx14aDoc*)m_pDocument;

    }#endif //_DEBUG

    /////////////////////////////////////////////////////////////////////////////// CEx14aView message handlers

    void CEx14aView::OnDrawCircle(){

    m_bCircle = TRUE;m_rect += CPoint(25, 25);InvalidateRect(m_rect);

    }void CEx14aView::OnUpdateDrawCircle(CCmdUI* pCmdUI){

    pCmdUI->Enable(!m_bCircle);}

    void CEx14aView::OnDrawPattern(){

    m_bPattern ^= 1;}void CEx14aView::OnUpdateDrawPattern(CCmdUI* pCmdUI){

    pCmdUI->SetCheck(m_bPattern);}

    void CEx14aView::OnDrawSquare(){

    m_bCircle = FALSE;m_rect += CPoint(25, 25);InvalidateRect(m_rect);

    }void CEx14aView::OnUpdateDrawSquare(CCmdUI* pCmdUI){

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    42/57

    42

    pCmdUI->Enable(m_bCircle);}

    Result:Thus the operations of a menu design using the vc++ as a front end and oracle as bank

    end as implemented and verified successfully.

    Ex.No:10 REPORTS - BANKING SYSTEM

    AIM

    To implement the operation of a banking system using the vb on front end and oracle as

    bank end.

    ALGORITHM

    Step 1 : Collect the details of how the program is expected by the user and also the

    atmosphere in which it is going to work.

    Step 2 : Collect the user requirements. Develop the sketch on the program.

    Step 3 : Implement the various diagrams carefully, based on which the entire project

    design is going to be developed.

    Step 4 : Thus the program is implemented successfully.

    SQL TABLE

    Create table det1(name varchar(20),acno number,addr varchar(20),actype varchar(20),amt

    number,pass varchar(20));

    PROGRAM

    Dim db As Database Dimrec As Recordset PrivateSub accept_Click()If Combo2.Text = "deposit" ThenLabel10.Caption = Val(Label10.Caption) + Val(Text6.Text)rec.Fields("amt") = Val(Label10.Caption)rec.Update

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    43/57

    43

    ElseIf Combo2.Text = "transaction" ThenForm4.ShowElseIf Val(Label10.Caption) >= 501 Then

    If Val(Label10.Caption) - Val(Text6.Text) >= 500 ThenLabel10.Caption = Val(Label10.Caption) - Val(Text6.Text)rec.UpdateElseMsgBox "min amt is 500", vbCritical, "below 500"End IfElseMsgBox "min amt is 500", vbCritical, "below 500"End IfEnd IfEnd Ifaccept.Enabled = FalseEnd Sub

    Private Sub cmdtra_Click()rec.MoveFirstFratrans.Visible = Not Fratrans.VisibleEnd Sub

    Private Sub cmdview_Click()fraview.Visible = Not fraview.VisibleshowrecEnd Sub

    Private Sub Combo1_Click()rec.MoveFirstDo While (rec.EOF = False)If (StrComp(rec.Fields("acno"), Combo1.Text) = 0) ThenLabel10.Caption = rec.Fields("amt")End Ifrec.MoveNextLoopaccept.Enabled = TrueEnd Sub

    Private Sub showrec()clearText1.Text = rec.Fields("name")Text2.Text = rec.Fields("acno")Text3.Text = rec.Fields("addr")Text4.Text = rec.Fields("actype")

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    44/57

    44

    Text5.Text = rec.Fields("amt")End Sub

    Private Sub first_Click()rec.MoveFirst

    showrecEnd Sub

    Private Sub Form_Load()Set db = OpenDatabase("bank", False, False, "odbc:uid=scott;pwd=tiger;dsn=bank")Set rec = db.OpenRecordset("select * from det1")

    MsgBox ("successfully connectted")With rec.MoveFirstDo While Not .EOFCombo1.AddItem .Fields(1)Combo2.AddItem "deposit"Combo2.AddItem "withdraw"Combo2.AddItem "transaction".MoveNextLoopEnd Withfraview.Visible = FalseFratrans.Visible = FalseEnd Sub

    Private Sub last_Click()rec.MoveLastshowrecEnd Sub

    Private Sub next_Click()rec.MoveNextIf rec.EOF = True ThenMsgBox "last record", vbCriticalrec.MoveLastEnd IfshowrecEnd Sub

    Private Sub previous_Click()rec.MovePreviousIf rec.BOF = True ThenMsgBox "first record", vbCriticalrec.MoveFirst

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    45/57

    45

    End IfshowrecEnd SubPrivate Sub clear()Text1.Text = ""

    Text2.Text = ""Text3.Text = ""Text4.Text = ""Text5.Text = ""End Sub

    FORM 2

    Dim db As DatabaseDim rec As RecordsetDim rec1 As RecordsetPrivate Sub Command1_Click()Form3.ShowEnd Sub

    Private Sub Command3_Click()Unload MeEnd Sub

    Private Sub Form_Load()Set db = OpenDatabase("bank", False, False, "odbc:uid=scott;pwd=tiger;dsn=bank")Set rec = db.OpenRecordset("select * from det1")MsgBox ("successfully connectted")

    End Sub

    Private Sub login_Click()Do While Not rec.EOFIf rec.Fields("name") = Text1.Text And rec.Fields("pass") = Text2.Text Then

    If rec.Fields("acno") = Text3.Text ThenUnload MeForm1.ShowExit SubEnd IfMsgBox "Accout no is not correct", vbCriticalEnd Ifrec.MoveNextLoopMsgBox "user name or password is not correct", vbCriticalText1.Text = ""

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    46/57

    46

    Text2.Text = ""Text3.Text = ""Text1.SetFocusEnd Sub

    FORM 3

    Dim db As DatabaseDimrec As RecordsetPrivate Sub Add_Click()rec.AddNewrec(0) = Text1.Textrec(1) = Text2.Textrec(2) = Text3.Textrec(3) = Text4.Textrec(4) = Text5.Textrec(5) = Text6.Textrec.UpdateMsgBox "record updated", vbInformation, "ok"Unload MeEnd Sub

    Private Sub Command1_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Text5.Text = ""Text6.Text = ""rec.AddNewEnd Sub

    Private Sub Form_Activate()Text1.SetFocusEnd Sub

    Private Sub Form_Load()Set db = OpenDatabase("bank", False, False, "odbc:uid=scott;pwd=tiger;dsn=bank")Set rec = db.OpenRecordset("select * from det1")MsgBox ("successfully connectted")End Sub

    FORM 4

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    47/57

    47

    Dim db As DatabaseDim rec As RecordsetDim a As IntegerPrivate Sub Command1_Click()

    Do While Not rec.EOFIf (StrComp(rec.Fields("acno"), Val(Text1.Text)) = 0) ThenIf (rec.Fields("amt") >= 501) Thena = rec.Fields("amt") - Val(Text3.Text)If (a >= 501) Thenrec.Fields("amt") = rec.Fields("amt") - Text3.Textrec.UpdateDo While Not rec.EOFIf (StrComp(rec.Fields("acno"), Val(Text2.Text)) = 0) Thenrec.Fields("amt") = rec.Fields("amt") + Val(Text3.Text)rec.UpdateEnd Ifrec.MoveNextLoopElseMsgBox "access denied", vbCritical, "below 500"End IfElseMsgBox "access denied", vbCritical, " below 500"End IfMsgBox "transaction successfully completed"End Ifrec.MoveNextLoopEnd Sub

    Private Sub Form_Load()Set db = OpenDatabase("bank", False, False, "odbc:uid=scott;pwd=tiger;dsn=bank")Set rec = db.OpenRecordset("select * from det1")MsgBox ("successfully connectted")End Sub

    FORM 1:

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    48/57

    48

    FORM 2:

    FORM 3:

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    49/57

    49

    FORM 4:

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    50/57

    50

    RESULT:Thus, the Banking management system using VB was implemented.

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    51/57

    51

    EXTRA PROGRAMS

    AGGREGATE FUNCTIONS

    AIM:

    To study the AGGREGATE FUNCTIONS and to execute them.

    GROUP FUNCTIONS

    Unlike single-row functions, group functions operate on sets of rows to give one result

    per group. These sets may be the whole table or the table split into groups.

    Types of Group Functions

    AVG COUNT

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    52/57

    52

    MAX MIN STDDEV

    SUM

    VARIANCE

    Function DescriptionEach of the functions accepts an argument. The following table identifies the options that youcan use in the syntax:

    INPUT:EMPLOYEES

    EMPNAME DEPARTMENT_ID JOB_ID SALARY

    Group Functions Syntax

    SELECT [column,]group_function(column), ...FROMtable [WHERE

    condition] [GROUP

    BYcolumn] [ORDERBYcolumn];

    Guidelines for Using Group Functions

    DISTINCT makes the function consider only nonduplicate values; ALL makes it considerevery value including duplicates. The default is ALL and therefore does not need to be specified.

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    53/57

  • 8/12/2019 Database Management Systems Lab

    54/57

    54

    1. COUNT(*) returns the number of rows in a table that satisfy the criteria of the SELECTstatement, including duplicate rows and rows containing null values in any of the columns. If aWHERE clause is included in the SELECT statement, COUNT(*) returns the number of rowsthat satisfies the condition in the WHERE clause.

    COUNT(*) returns the number of rows in a table.

    EXAMPLESELECT COUNT(*) FROM employees WHERE department_id = 50;

    2. In contrast, COUNT(expr) returns the number of non-null values in the column identified byexpr.

    EXAMPLEDisplay the number of department values in the EMPLOYEES table.

    SELECT COUNT(department_id) FROM employees;

    3. COUNT(DISTINCT expr) returns the number of unique, non-null values in the columnidentified by expr.

    EXAMPLESELECT COUNT(DISTINCT department_id)FROM employees;

    GROUP FUNCTIONS AND NULL VALUES

    All group functions ignore null values in the column.

    EXAMPLESELECT AVG(commission_pct) FROM employees;

    Using the NVL Function with Group Functions

    The NVL function forces group functions to include null values.

    EXAMPLE

    SELECT AVG(NVL(commission_pct, 0)) FROM employees;

    The GROUP BY ClauseYou can use the GROUP BY clause to divide the rows in a table into groups. You can then usethe group functions to return summary information for each group.

    In the syntax:SELECTcolumn,group_function(column)FROMtable

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    55/57

    55

    [WHEREcondition][GROUP BYgroup_by_expression]

    [ORDER BYcolumn];

    group_by_expression specifies columns whose values determine the basis for

    grouping rows.

    EXAMPLE

    SELECT department_id, AVG(salary)

    FROM employeesGROUP BY department_id ;

    When using the GROUP BY clause, make sure that all columns in the SELECT list that are notgroup functions are included in the GROUP BY clause.

    USING THE GROUP BY CLAUSE ON MULTIPLE COLUMNS

    EXAMPLE

    SELECT department_id dept_id, job_id, SUM(salary)

    FROM employeesGROUP BY department_id, job_id ;

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    56/57

    56

    The WHERE clause cannot be used to restrict groups. The SELECT statement on the slideresults in an error because it uses the WHERE clause to restrict the display of average salaries ofthose departments that have an average salary greater than $8,000.You can correct the slide errorby using the HAVING clause to restrict groups.

    EXAMPLE

    SELECT department_id, AVG(salary)FROM employeesHAVING AVG(salary) > 8000GROUP BY department_id;

    THE HAVING CLAUSEYou use the HAVING clause to specify which groups are to be displayed, and thus, you furtherrestrict the groups on the basis of aggregate information.

    In the syntax:SELECTcolumn,group_function

    FROMtable[WHEREcondition][GROUP BYgroup_by_expression]

    [HAVINGgroup_condition]

    [ORDER BYcolumn];

    group_condition restricts the groups of rows returned to those groups for whichthe specified condition is true.The Oracle server performs the following steps when you use the HAVING clause:1. Rows are grouped.2. The group function is applied to the group.

    3. The groups that match the criteria in the HAVING clause are displayed.The HAVING clause can precede the GROUP BY clause, but it is recommended that you placethe GROUP BY clause first because that is more logical. Groups are formed and group functionsare calculated before the HAVING clause is applied to the groups in the SELECT list.

    NESTING GROUP FUNCTIONSGroup functions can be nested to a depth of two.

    EXAMPLE

    Display the maximum average salary.

    SELECT MAX(AVG(salary))

    FROM employeesGROUP BY department_id;

    www.VidyarthiPlus.in

    Copyright : VidyarthiPlus.in

  • 8/12/2019 Database Management Systems Lab

    57/57

    57

    RESULT:Thus, the AGGREGATE FUNCTIONS were executed and the outputs

    were verified.

    www.VidyarthiPlus.in