Department of Computer Science & Engineering

141452– DBMS LAB

EXP.N0:1 DATA DEFINITION LANGUAGE [DDL] AIM: To execute the DATA DEFINITION LANGUAGE (DDL) commands. CREATING A TABLE SYNTAX: create table <table name> (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 <table name>; EXPLANATION: This command is used to view the structure of the table. EXAMPLE: SQL> desc student; Copyright : 2 OUTPUT: NAME NULL? TYPE VT NUMBER NAME VARCHAR (10) ALTERING A TABLE EXPLANATION: The structure of the table can be changed using this command like add new column, change the width of a datatype, change the datatype of a column. 1. MODIFY SYNTAX: alter table <table name> modify (column datatype, …); EXAMPLE: SQL> alter table student modify (name varchar (20)); OUTPUT: Table altered.

2. ADD / DROP SYNTAX: alter table <table name> add/drop (column datatype, …); EXAMPLE: SQL> alter table student add (dept varchar (20)); SQL> alter table student drop (addr); OUTPUT: Copyright : 3 Table altered. SYNTAX: TRUNCATING A TABLE truncate table <table name>; EXPLANATION: This command is used to delete all records stored in a table, but the structure of the table is retained. EXAMPLE: SQL> truncate table student; OUTPUT: Table truncated. DROPPING A TABLE SYNTAX: drop table <table name>; 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. Copyright : 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 <table name> 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 <table name> values (&value1, &value2,……, &value n); EXPLANATION: This insert command is used to add multiple rows to a table in the database. EXAMPLE: SQL> insert into student values (&vt, ‘&name’); Copyright : 5 OUTPUT: Enter value for vt: 4169 Enter value for name: rameeze Old 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 <table name>; 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 <field name> from <table name>; EXPLANATION: This select command is used to retrieve the particular field values stored in the table. EXAMPLE: SQL> select name from student; OUTPUT: NAME

Copyright : 6 RAMEEZE 3. SELECT USING WHERE COMMAND. SYNTAX: select <field name> from <table name> where <search condition>; EXPLANATION: This select command is used to retrieve the particular field values, stored in the table, which satisfy a required condition. EXAMPLE: SQL> select name from student where vt=4169; OUTPUT: NAME RAMEEZE UPDATE COMMAND SYNTAX: update <table name> set column1=expression, column 2=expression, ……, column n=expression where <search condition>; EXPLANATION: This command is used to update (changing values in) one or two columns of 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 Copyright : 7 SYNTAX: delete from <table name> where <search condition>; 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.

ROLLBACK: www. 2. COMMIT: 1. Syntax: COMMIT SAVEPOINT: It is not a command. It is logical unit of work. This command erases all save point and release the transaction lock.TRANSACTION CONTROL LANGUAGE: All changes made to the database is defined as a transaction. The transaction can made permanent to a database only they are committed. ROLLBACK This command is used to make all transaction changes permanent to the database. the previous user with privileges commands the database object ( 8 Rollback commands undo all the changes made in the current transaction. COMMIT 2. REVOKE Privilege Types of Privilege: . Copyright : VidyarthiPlus. The owner can allow other user to access his object as per his diversion the permission given by a user to another is called privilege. GRANT Privilege ii. The Data Control Commands are: i. Rollback b. The first one will rollback (undo) the entire transaction and the last one will undo all changes made after the creation of the save point id1.VidyarthiPlus. etc) of a user cant be accessed by another user without the permission of a user. Save point are used to divide as lengthy transaction into smaller ones. The two transaction control commands are: 1. DATA CONTROL LANGUAGE: Data control language. A transaction begins with an executable SQL statement. Syntax: a. Rollback to Save point id1. Syntax: Savepoint id. It is only a marker.

Select vii.A permission granted to execute the various data definition command like Create Table. SQL> Grant select. SQL> Select * from staff.VidyarthiPlus. Object Privilege: An Object Privilege enables a user to execute some commands on the database object like table view sequence etc. In this manner you can verify the following example:1. SQL> Grant create table to Copyright : VidyarthiPlus. SQL> Create user staff identified by guru. Staff master in a table in the user staff we first log on the staff [SQL> Connect staff/ 9 ii. SQL> Select * from staff. GRANT CREATE table TO anu. Insert iv. create session are called System Privilege. SQL> Connect system/managers. Granting System Privilege: Grant Command is used to give System Privilege to an oracle user. Revoking the permission: . SQL> Connect staff/guru. Delete vi. update. Some of the object privileges are i. SQL> Grant resource to staff.] SQL> Grant select insert on staff master to student. Update v. Create Sequence. SQL> Connect student/young. delete on student-master to staff. References Syntax: Grant object privilege [Object privilege] ON object to user [with grant option] Example: SQL> Grant Create session to student. Syntax: GRANT system privilege TO user Example: GRANT CREATE session TO anu. Alter www. Index iii. 2. Now log on to student and try the select command SQL> Connect student/young.

Permission granted to a user can also be taken back by the granter. FROM Example: select 11 15 . SQL> REVOKE SELECT ON STUDENT_MASTER from rajan. ii. Syntax: Revoke object privilege [object privilege] ON object name from user name. SELECT Example: select name from cust. Output: CITY harrison 3. INSERT ON STUDENT_MASTER from staff. Example: i. SQL> REVOKE SELECT. RENAME Example: select Copyright : VidyarthiPlus.VidyarthiPlus. Output: NAME CITY hayes harrison jones redwood blake downtown britto mounthill smith harrison 4. RESULT: www. Output: LOAN_ID 16 93 www. Output: NAME hayes jones blake 2. EXP.loan_no as loan_id from Copyright : VidyarthiPlus. WHERE Example: select city from cust where name= “hayes”. This can be done by the REVOKE command.N0:3 QUERIES IN SQL AIM: To write and execute queries in SQL. 1. city from cust. DCL and TCL commands are successfully executed and the output is 10 Thus the given DML.

AGGREGATE FUNCTIONS (a) AVERAGE. Example: select name from cust where city like ’har%’. Example: select city from cust where name like “_ _ _ _ _”. Output: NAME adams britto hayes jones smith 8. Output: AVG (BALANCE) Copyright : VidyarthiPlus. Output: NAME hayes jones 9.5 . Output: CITY harrison redwood downtown harrison 12 Example: (select name from depositor) intersect (select name from borrower). INTERSECTION www. STRING OPERATIONS (a) “%”.VidyarthiPlus. ORDERING OF TUPLES Example: select * from loan order by amount asc. Output: LOAN NO BRANCH AMOUNT 7. Example: select avg (balance) from account. UNION 11 roundhill 900 16 perryridge 1100 14 downtown 1500 15 perryridge 1500 17 redwood 2000 Example: (select name from depositor) union (select name from borrower). Output: NAME hayes smith (b) “_”.14 17 5.

Example: select total (balance) from account. Output: NAME hayes jones RESULT: Copyright : VidyarthiPlus.VidyarthiPlus. the queries in SQL were executed and the outputs were verified. Example: select min (balance) from account. (ii) You can present logical subsets or combinations of data by creating views of tables. A view is a logical table based on a table or another view.No:4 VIEWS AIM: To study the Simple View and Complex View and to execute them. Ex. Example: select count (balance) from account. Why Use Views? • To restrict data access • To make complex queries easy • To provide data independence • To present different views of the same data. Output: MIN (BALANCE) 350 (c) MAXIMUM. Example: select max (balance) from account. A view contains no data of its own but is like a window through which data from tables can be viewed or changed.(b) MINIMUM. The view is stored as a SELECT statement in the data dictionary. Output: SUM (BALANCE) 1950 (e) COUNT. Output: COUNT (BALANCE) 4 10. NESTED QUERIES Example: select name from depositor where depositor. Output: MAX (BALANCE) 700 (d) 13 cust).name in (select name from www. Views (i) Logically represents subsets of data from one or more tables. . The tables on which a view is based are called base tables.

in 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 VIEW statement. Simple Views versus Complex Views There are two classifications for views: simple and complex. One view can be used to retrieve data from several tables. . • 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. • Views provide data independence for ad hoc users and application programs. The basic difference is related to the DML (INSERT..Advantages of Views • Views restrict access to the data because the view can display selective columns from the table. alias]. EMPVU80. Syntax: CREATE [OR REPLACE] [FORCE|NOFORCE] VIEW view [(alias[. salary FROM employees WHERE department_id = 80. View created. and DELETE) operations. views can be used to query information from multiple tables without the user knowing how to write a join statement. • Views can be used to make simple queries to retrieve the results of complicated queries.)] AS subquery [WITH CHECK OPTION [CONSTRAINT constraint]] [WITH READ ONLY [CONSTRAINT constraint]]. – • The subquery can contain complex SELECT Example: • Create a view.. For example. UPDATE. • Views provide groups of users access to data according to their particular criteria.VidyarthiPlus. last_name. that contains details of employees in department 80. CREATE VIEW empvu80 AS SELECT Copyright : VidyarthiPlus.

View created. • Select the columns from this view by the given alias names. salary*12 ANN_SALARY FROM employees WHERE department_id = 50. last_name . * Create a view by using column aliases in the subquery. Retrieving Data from a View SELECT * FROM salvu50. Creating a Complex View Create a complex view that contains group functions to display values from two tables. minsal. CREATE OR REPLACE VIEW empvu80 (id_number.VidyarthiPlus. maxsal. CREATE VIEW salvu50 AS SELECT employee_id ID_NUMBER.ANN_SALARY) AS SELECT employee_id .• Describe the structure of the view by using the iSQL*Plus DESCRIBE command. name. department_id) AS SELECT employee_id. avgsal) . Modifying a View • Modify the EMPVU80 view by using CREATE OR REPLACE VIEW clause. www. (or) CREATE VIEW salvu50(ID_NUMBER. last_name NAME. department_id FROM employees WHERE department_id = 15 salary*12 FROM employees WHERE department_id = 50. • Column aliases in the CREATE VIEW clause are listed in the same order as the columns in the subquery. sal. View created. first_name || ’ ’ || last_name. Add an alias for each column name. Example: DESCRIBE empvu80 Assigning Names to Columns We Can Assign names for the various colmns in the view. View Copyright : VidyarthiPlus. CREATE VIEW dept_sum_vu (name. salary.NAME.

ALGORITHM: 1.department_id = d.AVG(e. RESULT: www. View Created. Create the function using function name.VidyarthiPlus.AS SELECT d. MAX(e. Syntax: DROP VIEW view. This is a requirement if any column of the view is derived from a function or an expression. Copyright : VidyarthiPlus.salary). Display the contents of the view by issuing a SELECT statement.salary) FROM employees e. Note that alternative names have been specified for the view. Declare the variables to be 17 Thus.N0:5 HIGH LEVEL PROGRAMMING LANGUAGE EXTENSIONS FUNCTIONS AND PROCEDURES AIM: To implement FUNCTIONS AND PROCEDURES using STRUCTURED QUERY LANGUAGE. maximum salaries. SELECT * FROM dept_sum_vu.department_id GROUP BY Copyright : VidyarthiPlus. the Simple view and Complex view were executed and the outputs were verified. View dropped. .department_name.department_name.salary). minimum salaries. EXP. You can view the structure of the view by using the iSQL*Plus DESCRIBE command. departments d WHERE e. and average salaries by department. MIN(e. Removing a View You can remove a view without losing data because a view is based on underlying tables in the 16 Creating a Complex View The example on the slide creates a complex view of department names. www. Example: DROP VIEW empvu80.

F2 (9) The number is odd. begin k: = n* Copyright : VidyarthiPlus. PROGRAM (c): SQL> select * from emp. begin r: = mod (a. End. SQL> select F1(3) from dual. . return k. end. if r=0 then return e. else return o. but helps to call a function. SQL> select F2 (9) from dual. 6. Return the value to the variable declared. e varchar 2(25):= ‘The number is even’. r number.VidyarthiPlus. PROGRAM (a): SQL> create or replace function F1 (n number) return number is k number. Procedure does not return value. F1 (3) 300 www. end. / OUTPUT: function created. Begin the function. Specify the operations. 6 rows selected. 2). endif. 5. 4. 18 PROGRAM (b): SQL> create or replace function F2 (a number) return char is o varchar 2(25):= ‘The number is odd’. / OUTPUT: function created.3.

end.put_line (‘Salary out of range. if ((sal>= minsal) and (sal<= maxsal)) then return (sal).VidyarthiPlus. begin select MIN (empsal). SQL> set serveroutput on. else dbms_output.put_line (‘Salary is in range and is’||a). dept number) return number is minsal 19 SQL>create or replace function F3 (sal Copyright : VidyarthiPlus.’).15 NO NAME SACHIN EMPSAL 9000 11 DEPT 16 SAURAV 9000 11 17 RAHUL 9000 01 18 YUVRAJ 7500 11 19 DHONI 6000 10 20 GAUTAM 5000 10 www. / OUTPUT: function created. maxsal number . end F3. MAX (empsal) into minsal. / OUTPUT: Enter the value for sal: 9000 Enter the value for dept. SQL> declare a number.: 01 . else return (0). endif. maxsal from emp where dept= dept1. &dept). endif. if a=0 then dbms_output. begin a: = F3 (&sal.

but doing so requires external function declarations. Examples Front End Tools: • Visual Basic • Visual C++ • Java • PHP • HTML 1. Remote Data Objects. Ex. new 4: a:= f3 (9000. Salary is in range and is 9000.No:6 FRONT END TOOLS Aim: To study about the various front end tools to design forms and reports.old 4 : a: = f3(&sal. the FUNCTIONS AND PROCEDURES were executed using SQL www. Scripting languages such as VBA and VBScript are syntactically similar to Visual Basic. 01).in Copyright : VidyarthiPlus. A programmer can put together an application using the components provided with Visual Basic itself.VidyarthiPlus. PL/SQL Procedure is successfully completed. but perform differently. access to databases using Data Access Objects. MICROSOFT VISUAL BASIC: Visual Basic (VB) is the third-generation event-driven programming language and integrated development environment (IDE) from Microsoft for its COM programming model. &dept).in 20 and the outputs were verified. Language features www. Visual Basic is relatively easy to learn and use. and creation of ActiveX controls and objects. Programs written in Visual Basic can also use the Windows API. RESULT: Thus. Microsoft's extended support ended in March 2008 and the designated successor was Visual Basic .NET (now known simply as Visual Basic).in . or ActiveX Data Objects. The final release was version 6 in 1998. Visual Basic was derived from BASIC and enables the rapid application development (RAD) of graphical user interface (GUI) applications.VidyarthiPlus.

the program can automatically translate the case of the text being entered. specifying attributes and actions of those components.. etc.) on the form (window). For example. The language not only allows programmers to create simple GUI applications. code can be inserted into the form resize event handler to reposition a control so that it remains centered on the form.Copyright : 21 Like the BASIC programming language. a simple program can be created without the programmer having to write many lines of code. and writing additional lines of code for more functionality. ActiveX controls. etc. Programming in VB is a combination of visually arranging components or controls on a form.g. or DLL files. but may be changed by the programmer. expands to fill up the form. but is primarily . but with faster computers and native code compilation this has become less of an issue. Visual Basic can create executables (EXE files). Although programs can be compiled into native code executables from version 5 onwards. Performance problems were experienced by earlier versions. but can also develop complex applications. By inserting code into the event handler for a key press in a text box. providing a dynamic application. This runtime is included by default in Windows 2000 and later. Since default attributes and actions are defined for the components. Default values are provided when the control is created. text boxes. but for earlier versions of Windows like 95/98/NT it must be distributed together with the executable. or even prevent certain characters from being inserted. A tool is used to place controls (e. Many attribute values can be modified during run time based on user actions or changes in the environment. they still require the presence of runtime libraries of approximately 1 MB in size. Controls have attributes and event handlers associated with them. buttons. Forms are created using drag-and-drop techniques. Visual Basic was designed to be easily learned and used by beginner programmers.

a drop-down combination box will automatically display its list and allow the user to select any element. A = B = C does not imply that the values of A. This allows for server-side processing or an add-in module. the programmer seldom needs to specify additional libraries. Characteristics Visual Basic has the following traits which differ from C-derived languages: • Multiple assignment available in C language is not possible. a Visual Basic component can have no user interface. such as populating a related list. but restrictions in the IDE do not allow the creation of some targets (Windows model DLLs) and threading models. although it will transform keywords into a standard case configuration and force the case of variable names to conform to the case of the entry within the symbol table.used to develop Windows applications and to interface database systems. Unlike many other programming languages. Since the more common components are included in the default project template. but can be made case insensitive if so desired. and instead provide ActiveX objects to other programs via Component Object Model (COM). C++). String comparisons are case sensitive by default. while programmers can insert additional logic within the appropriate event handlers. The language is garbage collected using reference counting. www. which can then execute additional code created by the programmer to perform some action based on which element was selected. Alternatively. An event handler is called when an item is 22 The Visual Basic compiler is shared with other Visual Studio languages (C. The . has a large library of utility Copyright : VidyarthiPlus. and has basic object oriented support. B and C are equal. Controls provide the basic functionality of the application. Visual Basic is generally not case sensitive. Dialog boxes with less functionality can be used to provide pop-up capabilities. For example. The Boolean result of "Is B = C?" is stored in A.VidyarthiPlus.

It is also possible to use the Option Base statement to set the default lower bound. • Boolean constant True has numeric value −1. MICROSOFT VISUAL C++ Microsoft Visual C++ (often abbreviated as MSVC or VC++) is a commercial (free version available). in other words True = Not False. It has tools for developing and debugging C++ . Arrays are declared by specifying the upper and lower bounds in a way similar to Pascal and FORTRAN. both the lower and upper bounds are programmable.result stored in A would therefore be either false or true. In this construct −1 evaluates to 16 binary 1s (the Boolean value True). and 0 as 16 0s (the Boolean value False). This uncommon trait does exist in Visual Basic . This again is a traditional feature of BASIC. 2. This inherent functionality becomes especially useful when performing logical operations on the individual bits of an integer such as AND. OR. Use of the Option Base statement can lead to confusion when reading Visual Basic code and is best avoided by always explicitly specifying the lower bound of the array. integrated development environment (IDE) product from Microsoft for the C. • Logical and bitwise operators are unified. This is unlike some Cderived languages (such as Perl).[4] This is because the Boolean data type is stored as a 16-bit signed integer. because it can also be set by declaration. In this way. This is apparent when performing a Not operation on a 16 bit signed integer value 0 which will return the integer value −1.[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 CPU instructions at the time.NET but not in VBScript. In more subscript-limited languages. C++. • Variable array base. the lower bound of the array is not variable. and C++/CLI programming languages. This lower bound is not limited to 0 or 1. XOR and Not. which have separate logical and bitwise operators.

• C 23 The predecessor to Visual C++ was called Microsoft C/C++. • C 2. and the Windows 3. based on Lattice C.0.0. and a new debugger. It was Cfront 2.code. • C 5.5 and a Microsoft QuickC for Windows 1. • C 6.0 was released in 1992. History www. Microsoft FORTRAN and the first 32 bit compiler for 80386 were also part of this project. o Professional – replaced C/C++ 7. and the Microsoft .5 was released in December 1993. It was being used inside Microsoft (for Windows and Xenix development) in early 1984. and added OLE 2.[5] • Visual C++ 1.[2] • Visual C++ 1. the DirectX API.0 added loop optimizations and Huge Model (arrays bigger than 64k) support.VidyarthiPlus. Included the ability to build both DOS and Windows applications. It was not K&R Copyright : VidyarthiPlus.0.0 added large model support. • C 3. especially code written for the Microsoft Windows API.0. 16-bit versions Microsoft C 1. and included an optional C++ front end.1 compliant[3] and available in two editions:[4] o Standard – replaced QuickC for Windows. an optimizing compiler.[6] It was the first version of Visual C++ that came only on CDROM. was Microsoft's first C product in 1983. It was extremely compatible with K&R and the later ANSI standard.5. which included MFC 2. included MFC 2. • .0. a source level debugger. a source browser. a source profiler. It shipped as a product in 1985.0 released in 1989.0 and ODBC support to MFC. • C/C++ 7. released in February 1993. It added global flow analysis.0.0 was the first version developed inside Microsoft.0 added optimizations and CodeView.NET Framework. It added built-in support for C++ and MFC 1. was the first version of Visual C++.[3] The Phar Lap 286 DOS Extender Lite was also included. There was also a Microsoft QuickC 2.1 SDK.

2 were updates for 2. which included Visual C++ 1. since Windows 95. It is the last.52b is similar to 1. which included MFC 3.VidyarthiPlus. Although released when 16-bit 1.0 available through subscription.x/DOS) projects. There was a Visual C++ 2. It is available through Microsoft Developer www. o 32-bit versions Visual C++ 1. • Visual C++ 4.1 and 2.Visual C++ 1. o Visual C++ 1.x also supported Win32s development. Microsoft included and updated Visual C++ 1.0 came bundled with the • .x releases up to 2. and both 16-bit and 32-bit version of the Control Development Kit (CDK) were 24 Network.0 (original name: Visual C++ 32-bit Edition) was the first version for 32bit development.52 were available as part of a subscription service.51 and 1.52. which included Visual C+ + 1. then codenamed "Chicago". which included MFC 4.0. and Windows NT had only a small market share. o Visual C++ 1.0. this version was ahead of its time.5. In many ways.x.5 as part of the 2.0 RISC Edition for MIPS and Alpha Copyright : VidyarthiPlus. o Visual C++ 2. It was also available in a bundle called Visual C++ 16/32bit Suite. development platform for Microsoft Windows 3. was not yet released. It is available through Microsoft Developer Network.0. was the first version to be 32-bit only. this release was almost a "lost generation".5 was available.52c was a patched version of 1. Visual C++ 2. • Visual C++ 2. and arguably most popular. was designed for Windows 95 and Windows NT.5. To allow support of legacy (Windows 3.52. but does not include the Control Development Kit. as well as a cross-platform edition for the Macintosh (68000 instruction set). As a result.0. it did not include support for OLE2 and ODBC. 4.

was a major upgrade from 4.Visual C++ 1. issues with this version under Windows XP.0.0.52 installation CD.NET 2002. The debugging issues can be solved with a patch called the "Visual C+ + 6.2.x version in that it also allowed compilation for the PowerPC instruction set. Version number 3. especially under the debugging mode (for example. There are. was released in 2002 with support for link time code generation and debugging runtime checks. and Visual C++ 4.0 and MFC 4.NET 2003 (known also as Visual C++ 7. which included MFC 7. however. was released in 1998. which accounted for some of its unpopularity among C++ developers • Visual C++ .1. which included MFC 7.[11] Available in four editions: o Learning o Professional o Enterprise o RISC • Visual C++ 6.0 is still quite popular and often used to maintain legacy projects. The new user interface used many of the hot keys and conventions of Visual Basic. Updates available through subscription included Visual C++ 4. [10] This was the final version with a cross-platform edition for the Macintosh available and it differed from the 2.21. and Visual C# and Managed C++. was released in 2003 along with.0.[9] • Visual C++ 4.1). which included MFC 6. which included MFC 4.0.NET 2002 (known also as Visual C++ 7. Visual C++ 6.0 (commonly known as VC6). • Visual C++ 5. which came with the Microsoft Game SDK (later released separately as the DirectX SDK).0.1 and was a major upgrade to Visual C++ .0 Processor Pack".2 did not support Windows 3. the values of static variables do not display).1.0).NET 1. • Visual C++ .0 was skipped to achieve version number parity between Visual C++ 4.x (Win32s) development.[16] The release was somewhat controversial since it did not include an expected update to MFC.2.NET 1. . .

0 has problems compiling MFC AppWizard projects that were created using Visual Studio 6.0.VidyarthiPlus. which included MFC 8. Initially it replaced a development environment consisting of tools added onto Visual C++ 6. • SP1 version also available in Microsoft Windows SDK Update for Windows Vista. Version number: 14. eMbedded Visual C++ was replaced as a separate development environment by Microsoft Visual Studio 2005. all applications compiled against the Visual C++ 2008 Runtimes (static and dynamic linking) will only work under Windows 2000 and 25 the original IDE if rewriting was not feasible.50727. the English language upgrade version of Visual Studio . Accordingly.NET 2003 shipped for minimal cost to owners of the English language version of Visual Studio .0 and dropped Managed C++ for C++/CLI. later included into SP1.NET 2.0) was released in November 2007. • eMbedded Visual C++ in various versions was used to develop for some versions of the Windows CE operating system. By default. so maintenance of legacy projects can be continued with www. A feature pack released for VC9. Visual C++ 2005 is the last version to be able to target Windows 98 and Windows Me. This version supports . With Visual C++ 2005. Visual C++ 8. This was the last version to support Windows 95 and NT 4.NET 2002. • Visual C++ 2005 (known also as Visual C++ 8. Managed C++ for CLI is still available via compiler options though. Microsoft also introduced Team Foundation Server.762 • Visual C++ 2008 (known also as Visual C++ 9. Managed C++ for CLI is still available via compiler options.0.It was considered a patch to Visual C++ .NET 2002.0).00. . was released in November 2005.5.0 as a target.NET 3. added support for C++ TR1 library Copyright : VidyarthiPlus.0. This version supports . It also introduced OpenMP.

this one would benefit only a minority of library writers than the majority of compiler end users.01 o RTM version.00.21006.[22] (However. for better IntelliSense and code-completion support. decltype. moving the TR1 components from std::tr1 namespace directly to std namespace).1: 16. partial support for C++0x. also available in KB2519277 update to Windows SDK v7. static_assert.NET Framework 4 (WinSdk v7.00.21003. The partial C++0x support mainly consists of six compiler features[25] (lambdas. all applications compiled against the Visual C++ 2010 Runtimes will only work under Windows XP SP2 and later. rvalue references. the IDE itself has version number 16. and performance improvements to both the compiler and generated code. rvalue references). and some library features (e.30319.01)[27] o RC version number: 16.01 (this is the version of compiler.[28] Version number: 16.01 • 64-bit versions Visual Studio 2005 Standard and Professional editions have x86-64 compiler support.0) was released on April 12.NET 4.Visual C++ 2010 (known also as Visual C++ 10. It uses a SQL Server Compact database to store information about the source code. 2010.[23]) This version adds a modern C++ parallel computing library called the Parallel Patterns Library. o Beta 2 version number: 16.0.1). Visual C++ 2010 does not support Intellisense for C++/CLI. also available in Windows SDK for Windows 7 and . and it is currently the latest stable release.30128.01 o SP1 version.40219.[24] This version is built around . Variadic templates were also considered.g.00.00. including IntelliSense information.[26] By default. . nullptr). but delayed until some future version due to lower priority which stemmed from the fact that unlike other costly-toimplement features (lambda. but supports compiling to machine code. significantly improved IntelliSense. auto.00.

such as the GNU Compiler for Java and GNU Class path. particularly for client-server web applications.[9][10] The original and reference implementation Java compilers. Programmers who wanted the 64-bit versions of the Visual C++ . It should be "robust and secure" 3. Others have also developed alternative implementations of these Sun 26 Java is a programming language originally developed by James Gosling at Sun Microsystems (now part of Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform. object-oriented language that is specifically designed to have as few implementation dependencies as possible. Prior to Visual C++ 2005. Principles There were five primary goals in the creation of the Java language: 1. virtual machines. object-oriented and familiar" 2. JAVA www. run anywhere. concurrent. Sun relicensed most of its Java technologies under the GNU General Public License. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. 3.VidyarthiPlus. It should execute with "high performance" . class-based. It should be "architecture-neutral and portable" 4. the Platform SDK was the only way for programmers to develop 64-bit Windows applications. It is intended to let application developers "write Copyright : VidyarthiPlus. The SDK included both a compiler and a Visual C++ 6.NET 2003 libraries (which are no longer available) had to contact libs7164microsoft." Java is currently one of the most popular programming languages in use. As of May 2007. and class libraries were developed by Sun from in compliance with the specifications of the Java Community Process.0 library for the IA64-target. It should be "simple. Java is a general-purpose.and Visual Studio 2008 Team Suite supports both x86-64 and IA-64. Java applications are typically compiled to byte code (class file) that can run on any Java Virtual Machine (JVM) regardless of computer architecture.

4 (February 6. threaded. 1998) • J2SE 1. threading.5. This is achieved by compiling the Java language code to an intermediate representation called Java byte www. 1997) • J2SE 1.3 (May 8.0 (September 30. along with their release dates: • JDK 1. 2006) • Java SE 7 (July 28. or in a Web browser for Java Copyright : VidyarthiPlus. However. instead of directly to platform-specific machine code. and 27 code.1 (February 19. Standardized libraries provide a generic way to access host-specific features such as graphics. which means that computer programs written in the Java language must run similarly on any hardware/operatingsystem platform. 1996) • JDK 1. Java byte code instructions are analogous to machine code.2 (December 8. 2004) • Java SE 6 (December 11. It should be "interpreted. and dynamic" Versions Major release versions of Java. Just-in-Time compilers were introduced from early stages that compile byte codes to machine code during runtime.VidyarthiPlus. the overhead of interpretation means that interpreted programs almost always run more slowly than programs compiled to native executables would. 2002) • J2SE 5. but are intended to be interpreted by a virtual machine (VM) written specifically for the host hardware.0 (January 23. 2011) Features of Java Java Platform One characteristic of Java is portability. Performance Programs written in Java have a reputation for being slower and requiring more memory than . 2000) • J2SE 1. End-users commonly use a Java Runtime Environment (JRE) installed on their own machine for standalone Java applications. A major benefit of using byte code is porting.

VidyarthiPlus. and the Java runtime is responsible for recovering the memory once objects are no longer in use. 4.HTML HTML is a language for describing web pages. the unreachable memory becomes eligible to be freed automatically by the garbage collector. Java programs' execution speed improved significantly with the introduction of Just-in-time compilation in 1997/1998 for Java 1. The programmer determines when objects are Copyright : VidyarthiPlus. Automatic memory management Java uses an automatic garbage collector to manage memory in the object lifecycle. and optimizations in the Java Virtual Machine itself. String Buffer class. etc. . Once no references to an object remain. typically when objects that are no longer needed are stored in containers that are still in use. If methods for a nonexistent object are called.). • HTML stands for Hyper Text Markup Language • HTML is not a programming language. Something similar to a memory leak may still occur if a programmer's code holds a reference to an object that is no longer needed.those written in C. optional assertions.0 code has approximately half the performance of C code. such as Hotspot becoming the default for Sun's JVM in 2000. a "null pointer exception" is thrown. Currently. Java 2.[26] However. the second tag is the end tag • Start and end tags are also called opening tags and closing tags HTML Documents = Web Pages • HTML documents describe web pages • HTML documents contain HTML tags and plain text • HTML documents are also called web pages The purpose of a web browser (like Internet Explorer or Firefox) is to read HTML documents and display them as web pages.1. the addition of language features supporting better code analysis (such as inner classes. it is a markup language • A markup language is a set of markup tags • HTML uses markup tags to describe web pages HTML Tags 28 HTML markup tags are usually called HTML tags • HTML tags are keywords surrounded by angle brackets like <html> • HTML tags normally come in pairs like <b> and </b> • The first tag in a pair is the start tag.

VidyarthiPlus.2).HTML File Extension? When you save an HTML file. BASICPAY NUMBER(10. 3. 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.VidyarthiPlus.2). Develop a sketch of the program about how it is going to appear in its final 29 Result: Thus the front-end languages like VB. in this tutorial we use a plain text editor (like Notepad) to edit HTML. Collect the details of how the program is expected by the user and also the atmosphere in which it is going to work. DEPARTMENT VARCHAR2(20). PF NUMBER( . www.GROSSALRY NUMBER(10.TOTDED NUMBER(10.htm or the .The browser does not display the HTML tags.EMPNAME VARCHAR2(15).in Copyright : VidyarthiPlus.2) HRA NUMBER(10. Thus the program is implemented successfully. NETPAY NUMBER(10.2)). www. Implement the various diagram carefully.2). no: 7 FORMS. VC++. We believe using a plain text editor is the best way to learn HTML. 5.HTM or .PAYROLL PROCESSING SYSTEMS AIM: To implement the operations of PAYROLL PROCESSING SYSTEM using the visual basic as front end and oracle as back end to design a forms. you can use either the . Java. it is entirely up to you. However.2). SQL TABLE: SQL>CREATE TABLE_DETAIL(EMPID NUMBER(5) CONSTRAINT CON PRIMARY KEY. 2. Table created. and HTML are studied. Ex. 6. DESIGNATION VARCHAR2(20). There is no difference.2). In the component diagram. ADDRESS VARCHAR(20). PROCEDURE: 1.INTAX NUMBER(10. using the update code command we generate the code for the required program.html file extension. Collect the user requirement. Assign the values as required by the program control settings. .. based on which the entire project design is going to be developed. 4.

in Copyright : VidyarthiPlus.SetFocus End sub Private sub cmdnext_Click() rs.Text=rs(“DEPARTMENT”) txtbasic.Text=rs(1) txtdes.Text=”” txtbasic.Text=”” rs.Text=rs(“DESINATION”) txtdept.Text=”” www.Text=rs(1) txtdes.Copyright : 31 txtdept.Text=”” txtename.Text=rs(0) 30 CODING: FORM 1: Dim db As Database Dim rs As Recordset Dim PF As Integer Dim HRA As Integer Dim DA As Integer Dim GROSSPAY As Integer Dim NETPAY As Integer Dim TOTDED As Integer Dim TAX As Integer Private sub cmdexit_Click() Unload Me End sub Private sub cmdfirst_Click() rs.AddNew txteno.Text=”” txtdes.VidyarthiPlus.MoveLast txteno.MoveNext .Text=rs(“BASICPAY”) End sub Private sub cmdlast_Click() rs.Text=rs(“DEPARTMENT”) txtbasic.Text=rs(“BASICPAY”) End sub Private sub cmdnew_Click() txteno.Text=rs(“DESINATION”) txtdept.MoveFirst txteno.Text=rs(0) txtename.

Text=rs(1) txtdes.Text) *0.Text=rs(0) txtename.VidyarthiPlus.3 MA=100 PF=600 TAX=Val(txtbasic.If rs.Show End sub Private sub cmdprev_Click() rs.Text=rs(“DESINATION”) txtdept.Text=rs(0) Copyright : VidyarthiPlus.MoveFirst Else txteno.Text=rs(“DEPARTMENT”) txtbasic.2 DA=Val(txtbasic.Text=rs(“BASICPAY”) End If End sub Private sub cmdpayroll_Click() Form2.Text)<8000) Then www.Text)>=5000) And Val(txtbasic.15 End If If(Val( 32 HRA=Val(txtbasic.Text) *0.MovePrevious If Not rs.Text)>=8000) Then HRA=Val(txtbasic.Text=rs(“BASICPAY”) Else MsgBox”Record pointer is in the first record” End If End sub Private sub cmdsave_Click() If (Val(txtbasic.1 DA=Val(txtbasic.Text=rs(“DESINATION”) txtdept.Text=rs(1) txtdes.Text)<5000)Then*0.Text=rs(“DEPARTMENT”) txtbasic.Text) *0.4 MA=200 PF=700 TAX=Val(txtbasic.Text) *0.15 DA=Val(txtbasic.Text) *0.5 .Text) *0.BOf Then txteno.1 End If If (Val(txtbasic.1 HRA=Val(txtbasic.Text) *0.EOF Then MsgBox”Record pointer is in the last record” rs.Text) *0.

vbInformation.uidvt4193.pwd=vt4193”) Set rs =db.False.Update MsgBox”Record updated successfully” txteno.ListIndex -1)>=0 Then .OpenRecordset(“select*from E_DETAIL”.AddNew rs(0)= Val(txteno.”Sucessful” End sub FORM2: www.Text=”” Copyright : VidyarthiPlus.VidyarthiPlus.dbOpenDynaset) MsgBox”Successfully connected with the Database”.Text) rs(5)= DA rs(6)= HRA rs(7)= PF rs(8)= MA rs(9)= GROSSPAY rs(10)= NETPAY rs(11)= TAX rs.Text=”” txtdes.Fasle.Text) rs(1)= Trim(txtename.Text=”” End sub Private sub Form_Load Set db = OpenDatabase(“E_DETAIL”.Text) * 33 Dim db As Database Dim rs As Recordset Private sub cmdexit_Click() Load Form1 Unload Me End sub Private sub cmdnext_Click() If(Combo1.Text) rs(4)= Val(txtbasic.Text)+HRA+DA+MA NETPAY= GROSSPAY-(PF+TAX) rs.MA=300 PF=800 TAX=Val(txtbasic. ”odbc.Text) rs(2)= Trim(txtdes.Text=”” txtdept.2 End If GROSSPAY= Val(txtbasic.Text) rs(3)= Trim(txtdept.Text=”” txtename.

Combo1.Text=rs(3) txtbasic.EOF Combo1.ListIndex = Combo1.Clear Do While Not rs.ListIndex +1 display Else MsgBox ”This is the last record” End If End sub Private sub Form_Load() Set db = OpenDatabase(“E_DETAIL”.Text=rs(4) txtda.Fasle.Text=rs(9) txtgross.Text=rs(6) www.Text=rs(8) txttax.Text=rs(7) txtpf.MoveNext Loop Combo1. ”odbc.ListIndex +1)>=0 Then Combo1.Text=rs(1) txtdes.Text=rs(5) txthra.OpenRecordset(“select*from E_DETAIL order by EMPID”) 34 txtma.Text=rs(11) End sub Private sub combo1_Click() rs.Text)) display .ListIndex=0 End sub Sub display() txtename.ListIndex -1 display Else MsgBox ”This is the first record” End If End sub Private sub cmdprev_Click() If(Combo1.MoveFirst rs.VidyarthiPlus.pwd=vt4202”) Set rs =db.False.FindFirst(“EMPID=”& val(Combo1.Text=rs(2) txtdept.MoveFirst Combo1.AddItem rs(0) Copyright : VidyarthiPlus.uidvt4202.ListIndex = Combo1.Text=rs(10) txtnetpay.

in 36 OUTPUT: begin update saldet set total = total+1500 where empno =:new. • Assign the new variables to those in tables. specifying the trigger name.VidyarthiPlus. • Declare the variables. 1 row updated. the payroll processing system using VB was implemented. • End.N0:8 TRIGGERS AIM: To create TRIGGERS on the database using SQL. • Specify whether the operation is delete/insert on rows or every statement.VidyarthiPlus. ALGORITHM: • Begin by creating the trigger. EXP. / trigger created.End sub Form 1: Form 2: Copyright : 35 RESULT: Thus. PROGRAM (a): INPUT: EMPLOY EMPNO SALARY 10 900 11 1000 12 1200 SALDET EMPNO DEPT TOTAL 10 11 900 SQL> create trigger triplet after update of salary on employ for each row Copyright : VidyarthiPlus. SQL> update employ set salary=1000 where empno=10.empno. end. EMPLOY EMPNO SALARY 10 1000 . • Specify the operation to be performed in the trigger.

m2 number(10).sal>1000 or :new.VidyarthiPlus.mark2. then raise_application_error ( 37 PROGRAM (c): INPUT: STUDENT VT NAME MARK1 MARK2 4170 Raja 60 73 SQL>create or replace trigger first before update on student for each row declare m1 number(10). Error at line 1: ORA -20001: mark1 should be less than mark2. SQL> update student set mark1 =80 where VT=4170. www. if m1> m2 then raise_application_error (-20001. begin m1:=:new.VidyarthiPlus. / OUTPUT: trigger created.’mark1 should be less than mark2’).’You are not allowed to insert. m2:=:new.’). SQL> update employ set salary =1200 where dept =10. end if. Error at line 1: ORA -20001: You are not allowed to insert.11 1000 12 1200 SALDET EMPNO DEPT TOTAL 10 11 2400 PROGRAM (b): SQL> create or replace trigger second before update on employ for each row begin if :new.mark1. / OUTPUT: trigger created. end.dept =10. . end if. Copyright : VidyarthiPlus.

h" #include " 39 Program: // ex14aView. Step 4: Thus the program is implemented successfully. www. CView) BEGIN_MESSAGE_MAP(CEx14aView. Step 2: Collect the user requirements. OnDrawPattern) ON_UPDATE_COMMAND_UI(ID_DRAW_PATTERN. OnUpdateDrawSquare) .h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = FILE . Step 3: Implement the various diagrams carefully. OnDrawCircle) ON_UPDATE_COMMAND_UI(ID_DRAW_CIRCLE. OnUpdateDrawPattern) ON_COMMAND(ID_DRAW_SQUARE. CView) //{{AFX_MSG_MAP(CEx14aView) ON_COMMAND(ID_DRAW_CIRCLE.VidyarthiPlus. OnUpdateDrawCircle) ON_COMMAND(ID_DRAW_PATTERN. the TRIGGERS were executed using SQL and the outputs were verified.Copyright : VidyarthiPlus. Copyright : VidyarthiPlus.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++.cpp : implementation of the CEx14aView class // #include "stdafx.h" #include "ex14a. based on which the entire project design is going to be developed. Develop the sketch on the program. #endif ///////////////////////////////////////////////////////////////////////////// // CEx14aView IMPLEMENT_DYNCREATE(CEx14aView.h" #include "ex14aDoc. OnDrawSquare) ON_UPDATE_COMMAND_UI( 38 RESULT: Thus.

www. 100) { m_bCircle = Copyright : VidyarthiPlus. } ///////////////////////////////////////////////////////////////////////////// // CEx14aView drawing void CEx14aView::OnDraw(CDC* pDC) { CBrush brush(HS_BDIAGONAL. 100. // brush with diagonal pattern if (m_bPattern) { pDC->SelectObject(&brush). 0L).//}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CEx14aView construction/destruction CEx14aView::CEx14aView() : m_rect(0. 0.VidyarthiPlus. // Deselects brush // if selected } ///////////////////////////////////////////////////////////////////////////// // CEx14aView diagnostics #ifdef _DEBUG void CEx14aView::AssertValid() const { .in 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). } if (m_bCircle) { pDC->Ellipse(m_rect). } else { pDC->SelectStockObject(WHITE_BRUSH). m_bPattern = FALSE. } pDC->SelectStockObject(WHITE_BRUSH). } else { pDC->Rectangle(m_rect).

25).in 41 void CEx14aView::Dump(CDumpContext& dc) const { CView::Dump(dc).in Copyright : VidyarthiPlus. } www. } void CEx14aView::OnUpdateDrawCircle(CCmdUI* pCmdUI) { pCmdUI->Enable(!m_bCircle).in . m_rect += CPoint(25. } CEx14aDoc* CEx14aView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx14aDoc))). InvalidateRect(m_rect). } void CEx14aView::OnDrawSquare() { m_bCircle = FALSE. InvalidateRect(m_rect). } void CEx14aView::OnUpdateDrawSquare(CCmdUI* pCmdUI) { www. } void CEx14aView::OnDrawPattern() { m_bPattern ^= 1.VidyarthiPlus.CView::AssertValid(). } void CEx14aView::OnUpdateDrawPattern(CCmdUI* pCmdUI) { pCmdUI->SetCheck(m_bPattern). return (CEx14aDoc*) Copyright : VidyarthiPlus. } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CEx14aView message handlers void CEx14aView::OnDrawCircle() { m_bCircle = TRUE. 25). m_rect += CPoint(25.VidyarthiPlus.

Text = "deposit" Then Label10.acno number.amt number. Develop the sketch on the program. Ex. Step 2 : Collect the user requirements.No:10 REPORTS . PROGRAM Dim db As Database Dim rec As Recordset Private Sub accept_Click() If Combo2.Text) >= 500 Then Label10.Caption) >= 501 Then If Val(Label10.Text = "transaction" Then Form4.Text) rec.Caption) + Val(Text6.42 pCmdUI->Enable(m_bCircle). 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.Caption = Val(Label10. } 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. Step 3 : Implement the various diagrams carefully.pass varchar(20)).Caption) rec.Caption = Val(Label10. SQL TABLE Create table det1(name varchar(20).Text) rec.Show Else If Val(Label10. Step 4 : Thus the program is implemented 43 Else If Combo2.Update Else .Update www.Val(Text6. based on which the entire project design is going to be developed.Fields("amt") = Val(Label10.Caption) .addr varchar(20).in Copyright : VidyarthiPlus.Val(Text6.actype varchar(20).BANKING SYSTEM AIM To implement the operation of a banking system using the vb on front end and oracle as bank end.Caption) .VidyarthiPlus.

Fields("acno") Text3.OpenRecordset("select * from det1") .Text = rec.Enabled = False End Sub Private Sub cmdtra_Click() rec.dsn=bank") Set rec = db. False. False.MoveFirst Fratrans.Fields("amt") End If rec.MoveNext Loop accept.VidyarthiPlus.Visible showrec End Sub Private Sub Combo1_Click() rec.Fields("addr") Text4. Combo1.Text = rec.Visible = Not fraview. "below 500" End If Else MsgBox "min amt is 500".MsgBox "min amt is 500".Fields("name") Text2.Fields("amt") End Sub Private Sub first_Click() rec. " 44 Text5.Caption = rec. "below 500" End If End If End If accept.pwd=tiger. vbCritical.Enabled = True End Sub Private Sub showrec() clear Copyright : VidyarthiPlus.Text) = 0) Then Label10.Fields("actype") www.Text = rec.Visible End Sub Private Sub cmdview_Click() fraview.Fields("acno").Visible = Not Fratrans. vbCritical.MoveFirst Do While (rec.MoveFirst showrec End Sub Private Sub Form_Load() Set db = OpenDatabase("bank".Text = rec.Text = rec.EOF = False) If (StrComp(rec.

AddItem "deposit" Combo2.Visible = False Fratrans.AddItem "withdraw" Combo2.AddItem "transaction" .in Copyright : VidyarthiPlus.EOF = True Then MsgBox "last record". vbCritical rec.AddItem .MoveFirst www.Fields(1) Combo2.Visible = False End Sub Private Sub last_Click() rec.MoveLast showrec End Sub Private Sub next_Click() rec.BOF = True Then MsgBox "first record".in 45 End If showrec End Sub Private Sub clear() Text1.EOF Combo1.VidyarthiPlus.Text = "" Text3.MoveLast End If showrec End Sub Private Sub previous_Click() rec.Text = "" Text2.MoveNext Loop End With fraview.MovePrevious If rec.Text = "" Text5.MsgBox ("successfully connectted") With rec .MoveFirst Do While Not .MoveNext If rec.Text = "" End Sub FORM 2 Dim db As Database . vbCritical rec.Text = "" Text4.

Dim rec As Recordset Dim rec1 As Recordset Private Sub Command1_Click() Form3.VidyarthiPlus.Fields("acno") = Copyright : VidyarthiPlus.SetFocus End Sub FORM 3 Dim db As Database Dim rec As Recordset Private Sub Add_Click() rec. vbCritical Text1. vbCritical End If rec.AddNew rec(0) = Text1. "odbc:uid=scott.Text = "" Text3.Show Exit Sub End If MsgBox "Accout no is not correct".EOF If rec.Text Then Unload Me Form1.Text .Text And rec.Text rec(4) = Text5.dsn=bank") Set rec = 46 Text2.Fields("name") = Text1.pwd=tiger.Fields("pass") = Text2.OpenRecordset("select * from det1") MsgBox ("successfully connectted") End Sub Private Sub login_Click() Do While Not rec.Text rec(3) = Text4.MoveNext Loop MsgBox "user name or password is not correct". False.Text rec(1) = Text2.Text = "" www.Text = "" Text1.Text Then If rec.Show End Sub Private Sub Command3_Click() Unload Me End Sub Private Sub Form_Load() Set db = OpenDatabase("bank".Text rec(2) = Text3. False.

Text = "" rec.Text = "" Text4.Text3.SetFocus End Sub Private Sub Form_Load() Set db = OpenDatabase("bank".Val(Text3.AddNew End Sub Private Sub Form_Activate() Text1. False. Val(Text2.Text)) = 0) Then If (rec.pwd=tiger.Update MsgBox "record updated".Text)) = 0) Then rec.Update Do While Not rec.Fields("amt") = rec.Text) rec.Fields("amt") >= 501) Then a = rec. False.Text = "" Text6.VidyarthiPlus.Text) If (a >= 501) Then rec.Fields("amt") . vbInformation.Fields("acno"). "ok" Unload Me End Sub Private Sub Command1_Click() Text1.EOF If (StrComp(rec.OpenRecordset("select * from det1") MsgBox ("successfully connectted") End Sub FORM 4 47 Dim db As Database Dim rec As Recordset Dim a As Integer Private Sub Command1_Click() Do While Not rec.Fields("acno").Update End If rec.MoveNext Loop Else .Fields("amt") .Text = "" Text3. "odbc:uid=scott.rec(5) = Text6.Text rec.dsn=bank") Set rec = db. Val( Copyright : VidyarthiPlus.Text rec.Fields("amt") = rec.Text = "" Text2.Fields("amt") + Val(Text3.EOF If (StrComp(rec.Text = "" Text5.

in 51 EXTRA PROGRAMS AGGREGATE FUNCTIONS AIM: To study the AGGREGATE FUNCTIONS and to execute Copyright : VidyarthiPlus. " below 500" End If MsgBox "transaction successfully completed" End If rec. www. Copyright : Copyright : VidyarthiPlus.VidyarthiPlus. vbCritical.VidyarthiPlus.OpenRecordset("select * from det1") MsgBox ("successfully connectted") End Sub FORM 1: www. the Banking management system using VB was implemented.MsgBox "access denied".MoveNext Loop End Sub Private Sub Form_Load() Set db = OpenDatabase("bank" 49 FORM 4: www. GROUP FUNCTIONS Unlike single-row functions. Types of Group Functions . These sets may be the whole table or the table split into groups.pwd=tiger. "odbc:uid=scott. group functions operate on sets of rows to give one result per group. "below 500" End If Else MsgBox "access denied".in 50 RESULT: 48 FORM 2: FORM 3: www. Copyright : VidyarthiPlus.dsn=bank") Set rec = db. vbCritical.VidyarthiPlus.

.in Copyright : VidyarthiPlus. To override this default Copyright : VidyarthiPlus. FROM table [WHERE condition] [GROUP BY column] [ORDER BY column]. DESC can be used in an ORDER BY clause. The following table identifies the options that you can use in the syntax: INPUT: EMPLOYEES EMPNAME DEPARTMENT_ID JOB_ID SALARY Group Functions Syntax SELECT [column. Guidelines for Using Group Functions • DISTINCT makes the function consider only nonduplicate values. You can use the MAX and MIN functions for any data typ. www. • The Oracle server implicitly sorts the result set in ascending order when using a GROUP BY clause. NUMBER. . . or COALESCE 53 • The data types for the functions with an expr argument may be 52 MAX MIN STDDEV SUM VARIANCE Function Description Each of the functions accepts an argument. The default is ALL and therefore does not need to be specified.] group_function(column). VARCHAR2. ALL makes it consider every value including duplicates.• • • • • • • AVG COUNT www..VidyarthiPlus.VidyarthiPlus. To substitute a value for null values. NVL2. use the NVL. or DATE. • All group functions ignore null values. Copyright : VidyarthiPlus. THE COUNT FUNCTION The COUNT function has three formats: 1. EXAMPLE SELECT COUNT(DISTINCT department_id) FROM employees.VidyarthiPlus. In contrast. EXAMPLE SELECT AVG(commission_pct) FROM employees. •COUNT(*) 2. non-null values in the column identified by expr. GROUP FUNCTIONS AND NULL VALUES All group functions ignore null values in the column. Note: AVG. EXAMPLE SELECT COUNT(*) FROM employees WHERE department_id = 50. COUNT(*) returns the number of rows in a table. VARIANCE. SELECT COUNT(department_id) FROM employees. COUNT(DISTINCT expr) returns the number of 54 1.EXAMPLE The following example displays the employee last name that is first and the employee last name that is the last in an alphabetized list of all employees. EXAMPLE Display the number of department values in the EMPLOYEES table. MAX(last_name) FROM employees. COUNT(*) returns the number of rows in a table that satisfy the criteria of the SELECT statement. including duplicate rows and rows containing null values in any of the columns. • COUNT(expr) 3. If a WHERE clause is included in the SELECT statement. and STDDEV functions can be used only with numeric data types. • COUNT(DISTINCT expr) www. COUNT(expr) returns the number of non-null values in the column identified by expr. 3. SELECT MIN(last_name). 2. COUNT(*) returns the number of rows that satisfies the condition in the WHERE clause. Using the NVL Function with Group Functions .

In the syntax: SELECT column.The NVL function forces group functions to include null values. AVG(salary) FROM employees GROUP BY department_id . job_id . AVG(salary) FROM employees HAVING AVG(salary) > 8000 . EXAMPLE SELECT department_id. group_function(column) FROM table www. EXAMPLE SELECT department_id.You can correct the slide error by using the HAVING clause to restrict groups. The SELECT statement on the slide results in an error because it uses the WHERE clause to restrict the display of average salaries of those departments that have an average salary greater than $8. SUM(salary) FROM employees GROUP BY department_id. www. job_id. USING THE GROUP BY CLAUSE ON MULTIPLE COLUMNS EXAMPLE SELECT department_id Copyright : VidyarthiPlus.VidyarthiPlus.VidyarthiPlus. When using the GROUP BY 56 The WHERE clause cannot be used to restrict groups. make sure that all columns in the SELECT list that are not group functions are included in the GROUP BY clause. The GROUP BY Clause You can use the GROUP BY clause to divide the rows in a table into Copyright : VidyarthiPlus. group_by_expression specifies columns whose values determine the basis for grouping 55 [WHERE condition] [GROUP BY group_by_expression] [ORDER BY column]. You can then use the group functions to return summary information for each group. EXAMPLE SELECT AVG(NVL(commission_pct. 0)) FROM employees.000.

2.VidyarthiPlus.GROUP BY department_id. group_condition restricts the groups of rows returned to those groups for which the specified condition is true. NESTING GROUP FUNCTIONS Group functions can be nested to a depth of two. Rows are grouped. The groups that match the criteria in the HAVING clause are displayed. www. group_function FROM table [WHERE condition] [GROUP BY group_by_expression] [HAVING group_condition] [ORDER BY column].VidyarthiPlus. 3. SELECT MAX(AVG(salary)) FROM employees GROUP BY department_id. The HAVING clause can precede the GROUP BY clause. and thus. EXAMPLE Display the maximum average salary. Groups are formed and group functions are calculated before the HAVING clause is applied to the groups in the SELECT Copyright : VidyarthiPlus. The Oracle server performs the following steps when you use the HAVING clause: 1. THE HAVING CLAUSE You use the HAVING clause to specify which groups are to be displayed. The group function is applied to the group. In the syntax: SELECT 57 RESULT: Thus. but it is recommended that you place the GROUP BY clause first because that is more logical. you further restrict the groups on the basis of aggregate . Copyright : VidyarthiPlus. the AGGREGATE FUNCTIONS were executed and the outputs were verified.

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.