RDBMS & VB MANUAL Sr. No.

Title of Assignment Write a ‘C’ program to design and develop a mini database system that should allow a user to create database tables, insert records in the tables and write and execute simple SQL like queries (involving only select and from clauses) to retrieve data from the database. The program should implement data dictionary and store data in tables using file system of the underlying operating system. Design and draw an ER/EER diagram using standard notations for given problem definition and convert this diagram into Database Tables. Create tables with ORACLE using SQL DDL statements. Use SQL DML statement such as INSERT, UPDATE and DELETE to insert the data into tables and to update/delete the data inserted into/from tables. Write and execute SQL queries to extract information from the table. Create and perform Database Operations using Oracle as Back End and VB as Front End. Use ODBC connectivity and also with DSN / Without DSN Oriented Connectivity Design a Data Report using MS ACCESS and VB and also Oracle and VB. a) Create a PL/SQL Block to convert the number. b) Write a PL/SQL Block which use Cursor FOR LOOP to select 5 highest earners from EMP table and write their details into Message Table. a) Write a Procedure on EMP Table, it should increase commission of an Employee. Emp. No. and Comm. are passed as parameters to the Called Procedure. If Commission is found to be Null, procedure should generate user defined Error Message. b) Write a Function which accepts Input as a number and prints whether it is EVEN or ODD. Create a Trigger that audits the operations of EMP Table Write and Execute Embedded SQL Queries using C/C++ as a host language. Write and execute Dynamic SQL Query Write a program in VB to generate Student Information using VB Controls. Write a program in VB to implement Scientific Calculator using Programming Constructs of VB. Write a program to develop a Notepad Application using VB. Use concepts of Menus and Events Build simple animation with Picture Control

1

2

3

4 5

6

7

8 9 10 11 12. 13. 14

1

RDBMS & VB MANUAL 15 16 17. 18. Build a program which will allow user to select a file in a particular directory on a particular drive. Use drive list box control , directory list control and file list control. Design a multimedia player which can play movie and songs in standard formats Create a database using MS-ACCESS and perform different data handling operations using Database Control of VB. Perform Packaging and Deployment for a VB Application. a) Write a Program to accept a matrix, display, and provide a menu with options as follows 1)To find minimum element in the matrix 2)To find maximum element in the matrix b) Write a Program for File handling with following options 1) Open 2) Close 3) Add record 4) Read record

19

Assignment No. 01 Title of Assignment: Write a ‘C’ program to design and develop a mini database system that should allow a user to create database tables, insert records in the tables and write and execute simple SQL like queries (involving only select and from clauses) to retrieve data from the database. The program should implement data dictionary and store data in tables using file system of the underlying operating system. Relevant Theory / Literature Survey: (Brief Theory Expected) File Processing System: Here, application programs are written by system programmers according to the need of the organization. It is supported by conventional operation system. Here permanent records are stored in various files and different application programs are written to extract records, add recs. etc into appropriate files. Simulation of SQL is implemented using File Processing System. There are many disadvantages of using File Processing systems in storing and retrieving huge amount of data. They are, 1. Data Redundancy and Inconsistency: Since data files and application programs 2

RDBMS & VB MANUAL are created by different programmers over a long period of time, the data files may have different formats, program files may be written in several programming languages which causes redundancy. If the values of common fields are not matching for some records in both files, then it results in inconsistency of data. Difficulty in accessing data: It does not allow needed data to be retrieved in a Convenient and efficient manner. Data Isolation: Because data are scattered in various files and in different formats, it is difficult to write new application programs to retrieve appropriate data. Integrity Problems: Data values stored in the database must satisfy certain constraints and when new constraints are added it is difficult to change the programs to enforce them. Atomicity Problems: In conventional File processing system when the system fails it is difficult to ensure that the data are restored to consistent state prior to failure. Concurrent Access Anomalies: It does not allow multiple users to update the data simultaneously. Security Problems: It is difficult to provide access to particular data for specific users only.

2. 3. 4. 5. 6. 7.

On contrary DBMS (I-e) Data Base Management System provides an environment that is both convenient and efficient in retrieving and storing database information. Examples of DBMS are Oracle, Access, FoxPro, SQL Server etc. Design Analysis / Implementation Logic: (Algorithm / Flow Chart / Pseudo Code / UML diagram / DFD as per requirement) Data Structures used: 1. Structure used to store data in FILE which is going to be treated as the table. 2. Char Array to store the Query. Functions Used: 1. Create table: Function used to create table and enter records into it. 2. Prompt: To display SQL prompt. 3. Display: Function used to display table contents depending on the query entered. Algorithm: 1. Start. 2. Create the table. 3. Display SQL Prompt. 4. Read the query at the prompt. 5. Process the query. 6. Display the contents of the table as per the query entered. 7. Stop. Queries to be Implemented: 1. Select * from table : This query displays all the contents of the table. 3

RDBMS & VB MANUAL 2. Select field1, field2 from table : This query displays contents of selected fields from the table. 3. Select * from table where condition : This query displays contents of records of the table which satisfy the given condition. 4. Select * from table where condition1 AND condition2 : This query displays all the contents of all records of the table which satisfy both condition1 and condition2. 5. Select field1 , field2 from table where condition : This query displays contents of selected fields which records satisfy the condition Testing: Sample Database (Table) Student Table: Fields: Rno, Name and Class. Table to be displayed Rno Name 1 ABC 2 XYZ 3 PQR 4 STU

Class SE TE BE FE

1. I/P QUERY: SELECT * FROM STUDENT O/P: Rno Name Class 1 ABC SE 2 XYZ TE 3 PQR BE 4 STU FE 2. I/P : SELECT NAME, RNO FROM STUDENT O/P : Rno 1 2 3 4 3. I/P : O/P : 2 XYZ TE 4. I/P : SELECT * FROM STUDENT WHERE RNO > 1 AND RNO < 4 O/P : 2 XYZ TE 3 PQR BE 5. I/P : SELECT RNO,CLASS FROM STUDENT WHERE CLASS = TE 4 Name ABC XYZ PQR STU

SELECT * FROM STUDENT WHERE RNO=2

RDBMS & VB MANUAL O/P: 2 TE

Conclusion : Thus we have designed and developed a mini-database system using C program.

5

RDBMS & VB MANUAL

Assignment No. 2
Title of Assignment : Design and draw an ER/EER diagram using standard notations for given problem definition and convert this diagram into Database Tables. Relevant Theory / Literature Survey: (Brief Theory Expected) .Data Model Data Model is collection of conceptual tools for describing • data • data relationship • data semantics and • consistency constraints Data Model are classified into three types 1.Object Based logical model (a) ER Model (b) Object oriented model (c) Function Model 2.Recored-Based logical Model (a)Relationship Model (b)Network Model (c)Hierarchical Model 3.Physical Model (a)Unifying Model (b)Frame Memory Entity-Relationship Diagram:An E-R diagram can express the overall logical structure of a database graphically. ER diagrams are simple and clear-qualities that may well account in large part for the Widespread use of the E-R Model. Such a diagram consist of the following major component. Rectangles:- which represents entity set Ellipses:-which represent attribute Diamonds:-which represent relationship sets Lines:-Which link attributes to entity sets and entity set to relationship sets. Double Ellipses:- which denote derived attributes Double Lines:- which indicates total participation of entity in a relationship set Double Rectangles:- which represents weak entity sets. Extended ER Features:Following are the Extended Entity Relationship Features of E-R Model 1.Specialization 2.Generalization 3.Aggretion 4.Attributes Inheritance Specialization:It is the process of designing sub groupings within an entity set. Consider an account entity which can be classified into • Saving Account • Checking’s Account Checking account can be further be classified into • Standard • Gold • Senior 6

RDBMS & VB MANUAL Hence, Specialization of account entity is savings account and checking account Specialization of checking account is standard, gold and senior checking account. In E-R diagram, Specialization is depicted by a triangle component labeled ISA. Generalization:It is a containment relationship that exists between a higher level entity set and one more lower level entity set .Attributes of higher level entity set and of lower level entity set are common. this commonality is express by generalization Aggregation:Aggregation is an abstraction through which relationship are treated as higher-level entities.It helps to express relationship among relationships. To illustrate the need of aggregation consider the database describing information about employees who work on particular project and use a number of different machines in their work. Attributes Inheritance: A crucial property of the higher and lower level entity created by specialization and generalization is “attribute inheritance” .The attributes of higher of higher-level entity set are said to be inherited by the lower-level entity set .A lower level entity sets(or subclass) also inherits participation in the relationship sets in which its higher-level entity(or super class) participates. Design Analysis / Implementation Logic:
(Algorithm / Flow Chart / Pseudo Code / UML diagram / DFD as per requirement)

Steps in E-R Modeling • Identify the entities • Find relationships • Identify key attributes for every entity • Identify other relevant attributes • Draw complete E-R diagram with all attributes including Primary key. Testing:
(Input/ Output)

Case Study – ER Model For a college DB Assumptions : • A college contains many departments • Each department can offer any number of courses • Many instructors can work in a department • An instructor can work only in one department • For each department there is a Head • An instructor can be head of only one department • Each instructor can take any number of courses • A course can be taken by only one instructor • A student can enroll for any number of courses • Each course can have any number of students Step 1: Identify the Entities • DEPARTMENT • STUDENT • COURSE • INSTRUCTOR Step 2: Find the relationships • One course is enrolled by multiple students and one student enrolls for multiple 7

RDBMS & VB MANUAL courses,hence the cardinality between course and student is Many to Many. • The department offers many courses and each course belongs to only one department, hence the cardinality between department and course is One to Many. • One department has multiple instructors and one instructor belongs to one and only one department , hence the cardinality between department and instructor is one to Many. • Each department there is a “Head of department” and one instructor is “Head of department “,hence the cardinality is one to one . • One course is taught by only one instructor, but the instructor teaches many courses,hence the cardinality between course and instructor is many to one. Step 3: Identify the key attributes • Deptname is the key attribute for the Entity “Department”, as it identifies the Department uniquely. • Course# (CourseId) is the key attribute for “Course” Entity. • Student# (Student Number) is the key attribute for “Student” Entity. • Instructor Name is the key attribute for “Instructor” Entity. Step 4: Identify other relevant attributes • For the department entity, the relevant attribute is location • For course entity, course name,duration,prerequisite • For instructor entity, room#, telephone# • For student entity, student name, date of birth Step 5: Draw complete E-R diagram with all attributes including Primary Key

Conclusion: Thus we have studied and implemented the ER-Model for college DB.

Assignment No. 3
8

RDBMS & VB MANUAL Title of Assignment : Create tables with ORACLE using SQL DDL statements. Use SQL DML statement such as INSERT, UPDATE and DELETE to insert the data into tables and to update/delete the data inserted into/from tables. Write and execute SQL queries to extract information from the table. Relevant Theory / Literature Survey: (Brief Theory Expected) SQL • SQL is used to make a request to retrieve data from a Database. • The DBMS processes the SQL request, retrieves the requested data from theDatabase, and returns it. • This process of requesting data from a Database and receiving back the results is called a Database Query and hence the name Structured Query language • SQL is a language that all commercial RDBMS implementations understand. • SQL is a non-procedural language • We would be discussing SQL with respect to oracle syntax Components of SQLSQL is Comprised of three sub languages. They are data definition(DDL). Data Manipulation (DML) and data control language(DCL). 1.Data Definition Language(DDL) It consist of set of commands used to create the database objects such as tables, view and indexes .This include commands like create, alter and draw. 2.Data Manipulation Language(DML) It is used for query, insertion , updation and deletion of data stored in database .This include commands like select insert and update. 3.Data Control Language(DCL) It is used for controlling access to the data. This include commands like select Grant Rollback, Commit and Revoke. Limitation Of SQL It is not possible to include the declaration and also not possible to use variables and constants which are supporting constructs to control the flow of execution. Design Analysis / Implementation Logic: (Algorithm / Flow Chart / Pseudo Code / UML diagram / DFD as per requirement) Queries to be Implemented :1 CREATE - to create objects in the database Syntax: Create table <Table Name>(<columName1><Datatype>(<size>),<columName2><Data type>(<size>)); The different constraints can be used while creating the table. 1.NULL Constraint It Specifies that a column contain NULL Variable. 2.NOT NULL Constraint It specifies that a column cannot contain a NULL value. 3.PRIMARY KEY It designates a column or combination of columns as a primary key. It satisfies NOT NULL and UNIQUE constraint implicitly. 4.REFERENCES Identifies the Primary Key i.e. referenced by a foreign key in referential integrity constraint. 5.FOREIGN KEY It designates a column or combination of columns as foreign key in referential integrity constraint. 6.CHECK It specifies a condition that each row in a table must satisfy. 9

RDBMS & VB MANUAL 2 ALTER - alters the structure of the database Syntax: ALTER TABLE tablename (ADD/MODIFY/DROP column_name); 3 DROP - delete objects from the database Syntax: DROP TABLE <TableName>; 4 TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed. Syntax: TRUNCATE TABLE <TableName>; 5 INSERT - insert data into a table Syntax: INSERT INTO tablename (Columnlist) VALUES (value list); 6 SELECT - retrieve data from the a database Syntax: Select<columnname1>,<columnname2> from <table name>; Select * from <table name>; Select * from <table name> where <condition>; 7 UPDATE - updates existing data within a table Syntax: UPDATE tablename SET column_name =value [ WHERE condition] 8 DELETE - deletes all records from a table, the space for the records remain Syntax: DELETE FROM tablename WHERE condition SQL - Aggregate functions :• Used when information you want to extract from a table has to do with the data in the entire table taken as a set. • Aggregate functions are used in place of column names in the SELECT statement • The aggregate functions in sql are : SUM( ) , AVG( ) , MAX( ) , MIN( ), COUNT( ) SUM ( [ DISTINCT ] Column-name / Expression ) AVG ( [ DISTINCT ] Column-name / Expression ) MIN ( Expression ) MAX ( Expression ) COUNT ( [ DISTINCT ] Column-name ) Count( * ) Testing: (Input/ Output) CREATE TABLE Customer_Details( Cust_ID Number(5) CONSTRAINT Nnull1 NOT NULL, Cust_Last_Name VarChar2(20) CONSTRAINT Nnull2 NOT NULL, Cust_Mid_Name VarChar2(4), Cust_First_Name VarChar2(20), Account_No Number(5) CONSTRAINT Pkey1 PRIMARY KEY, Account_Type VarChar2(10) CONSTRAINT Nnull3 NOT NULL, Bank_Branch VarChar2(25) CONSTRAINT Nnull4 NOT NULL, Cust_Email VarChar2(30) ); ALTER TABLE Customer_Details ADD Contact_Phone Char(10); 10

RDBMS & VB MANUAL ALTER TABLE Customer_Details MODIFY Contact_Phone Char(12); ALTER TABLE Customer_Details DROP (Contact_Phone); DROP TABLE UnqTable; TRUNCATE TABLE Customer_Details; INSERT INTO Customer_Details VALUES (106, 'Costner', 'A.', 'Kevin', 3350, 'Savings', 'Indus Bank', 'Costner_Kevin@times.com'); SELECT * FROM Customer_Details; SELECT Cust_First_Name FROM Customer_Details; SELECT Cust_ID, Account_No FROM Customer_Details WHERE Cust_First_Name = ‘Graham’; UPDATE Customer_Fixed_Deposit SET Cust_Email = ‘Quails_Jack@rediffmail.com’ ,Rate_of_Interest_in_Percent = 7.3 WHERE Cust_ID = 104 ; DELETE FROM Customer_Details; DELETE FROM Customer_Details WHERE Cust_ID = 102; SELECT MIN (Total_Available_Balance_in_Dollars) FROM Customer_Transaction; SELECT MAX (Total_Available_Balance_in_Dollars) FROM Customer_Transaction; SELECT AVG (Total_Available_Balance_in_Dollars) FROM Customer_Transaction; SELECT MIN (Total_Available_Balance_in_Dollars), SUM (Total_Available_Balance_in_Dollars) FROM Customer_Transaction; SELECT COUNT (*) FROM Employee_Manager; SELECT COUNT (Manager_ID) FROM Employee_Manager; Conclusion: Thus we have studied and understood SQL .

11

RDBMS & VB MANUAL

Assignment No. 4
Title of Assignment: Create and perform Database Operations using Oracle as Back End and VB as Front End. Use ODBC connectivity and also with DSN / Without DSN Oriented Connectivity Relevant Theory / Literature Survey: (Brief Theory Expected) 1. Difference in ADODC and ADODB 2.What is DAO, RDO, ADO? 3.Design-time properties of ADODC • With MS Access • With Oracle 4. Setting properties of ADODC programmatically Design Analysis / Implementation Logic:
(Algorithm / Flow Chart / Pseudo Code / UML diagram / DFD as per requirement)

Oracle connectivity using ODBC(with DSN). To create a Data source Name(DSN) use following links/Step Links/steps: 1.Go to setting->control panel->Administrative Tools 2.Select Data Sources 3.Select User DSN 4.Click on Add And Select Driver as “Microsoft ODBC For Oracle” 5.Give Following Details Data Source name Description User Name Server To connect VB to Oracle use the following step 1.Define the variables as dim cnn as new ADODB.Connetion -Connection Object Dim rs as New ADODB.Recordset -Access to Individual Records 2. Use Following Statements for opening the connection cnn.open “dsn=dsnname; uid=Scott; pwd=tiger” rskk.open”Select * from Tablename”,cnn, adopenkeyset.adlockoptimistic. Now oracle get connected to vb with the provided username Oracle Connectivity without DSN Here it is not needed to create any DSN.So the Same Application can be used without any changes to the local computer. Use the following statements to open the connetion.the variables declaration is same as in DSN Cnn.Provider=”MSDAORA’ ;User id=’scott’; Password=’tiger’;data source=’mcoe’”; Cnn.open

12

RDBMS & VB MANUAL Testing:
(Input/ Output):

Connectivity with Oracle and MS-Access is established successfully

Conclusion: Thus we have created and performed database operations using ODBC.

Assignment No. 5
13

RDBMS & VB MANUAL Title of Assignment: Design a Data Report using MS ACCESS and VB and also Oracle and VB. Relevant Theory / Literature Survey: (Brief Theory Expected) Writing Reports with Microsoft Data Report Designer The Microsoft Data report Designer is versatile data report generator that features the ability to control banded hierarchical reports. Used in conjunction with a data report source such as the Data Environment Designer, you can also create reports from several different relational tables. In addition to creating printable reports you can also export to HTML or text files. Possible Uses • Automatically create reports that are exported in HTML format for instant distribution on the internet. • Create reports that show the sums of transactions occurring on a daily basis. Data Report Designer Features The data report designer has several Features: 1. Drag-and drop functionality for fields 2. ToolBox Controls 3. Prints Preview 4. Print Reports 5. Prints Reports 6. Export Templates 7. Asynchronous Operation The Data Report Designer Consist of following objects: 1. Data Report Object 2. Selection Object 3. Data Report Controls Section of Data Report Designer 1. Report Header 2. Page Header 3. Group Header/Footer 4. Details 5. Page footer 6. Report Footer Data Report Controls 1.TextBox Control 2.Label Control 3.Image control 4. Line Control 5. Shape Control 6.Function Control Design Analysis / Implementation Logic: (Algorithm / Flow Chart / Pseudo Code / UML diagram / DFD as per requirement) Step For creating Data Report 1.Create a new Standard EXE Project 2.On the Project Menu, Click Add Data Environment to add designer to your project 3.On project Menu, click Add Data Report, And visual Basic will add it to your project 4.Go to project environment, right click on Connection1 and click on the properties 5. Select provider as ‘Microsoft Jet 3.52 OLEDB Provider’. Click on next. 6.Right Click On connetion1 and click on Add Command 7.Click on command1,go to properties 14

RDBMS & VB MANUAL 8.Select source of Data By a. Database Object and Object name b. SQL Statement 9. In Command1,the Attributes of selected table will be added. 10.Drag and Drop the attributes to DataReport1 in section1 (details). 11 Run the Project Testing:
(Input/ Output):

Created the Data reports with VB- Oracle and VB-Access. Conclusion: Thus we have studied and understood Report creation using Visual Basic DataReport Designer

15

RDBMS & VB MANUAL

Assignment No. 6
Title of Assignment: PL/SQL Programming a)Write a PL/SQL block to convert the given number. b) Write a PL/SQL Block which use Cursor FOR LOOP to select 5 highest earners from EMP table and write their details into Message Table. Relevant Theory / Literature Survey: (Brief Theory Expected) PL/SQL stands for Procedural Language/SQL. PL/SQL extends SQL by adding constructs found in procedural languages, resulting in a structural language that is more powerful than SQL. The basic unit in PL/SQL is a block. All PL/SQL programs are made up of blocks, which can be nested within each other. Typically, each block performs a logical action in the program. A block has the following structure:
DECLARE  Declaration block (optional) /* Declarative section: variables, types, and local subprograms. */  BEGIN * Executable section: procedural and SQL statements go here. */ /* This is the only section of the block that is required. */ EXCEPTION  Exception-handling (optional) /* Exception handling section: error handling statements go here. */ END /* Sample comment spanning multiple lines... */ The DECLARE section specifies the datatypes of variables, constants, collections, and user-defined types.

The block between BEGIN and END specifies executable procedural code. Exceptions, errors which arise during the execution of the code, have one of two types: 1. pre-defined exceptions 2. user-defined exceptions. Programmers have to raise user-defined exceptions explicitly. They can do this by using the RAISE command, with the syntax: RAISE <exception name> Oracle Corporation has pre-defined several exceptions like NO_DATA_FOUND, TOO_MANY_ROWS, etc. Each exception has a SQL Error Number and SQL Error Message associated with it. Programmers can access these by using the SQLCODE and SQLERRM functions. Cursors :-A cursor is a variable that runs through the tuples of some relation. This relation can be a stored table, or it can be the answer to some query. By fetching into the cursor each tuple of the relation, we can write a program to read and process the value of each such tuple. If the relation is stored, we can also update or delete the tuple at the current cursor position. 16

RDBMS & VB MANUAL

PL/SQL uses two types of cursors: implicit and explicit. PL/SQL declares a cursor implicitly for all SQL data manipulation statements, including queries that return only one row. However, for queries that return more than one row, you must declare an explicit cursor or use a cursor FOR loop. Each cursor or cursor variable has four attributes: %FOUND, %ISOPEN %NOTFOUND, and %ROWCOUNT. When appended to the cursor or cursor variable, these attributes return useful information about the execution of a data manipulation statement. You can use cursor attributes in procedural statements but not in SQL statements. Cursor For Loops :- In most situations that require an explicit cursor, you can simplify coding by using a cursor FOR loop instead of the OPEN, FETCH, and CLOSE statements. A cursor FOR loop implicitly declares its loop index as a %ROWTYPE record, opens a cursor, repeatedly fetches rows of values from the result set into fields in the record, and closes the cursor when all rows have been processed. Syntax :- For memory variable IN CursorName Design Analysis / Implementation Logic:
(Algorithm / Flow Chart / Pseudo Code / UML diagram / DFD as per requirement)

Algorithm for part a :1) Calculate the length of the given number. 2) Initialize the loop such that it repeats for the number of times equal to the length of given number , also loop should consider the last number first and store it i.e. in reverse order. 3) Obtain the last digit of the number using substr function and stored in a variable. 4) Display the initial number as well as inverted number. Testing:
(Input/ Output):

Conclusion: We have studied PL/SQL Programming.

17

RDBMS & VB MANUAL

Assignment No. 7
Title of Assignment: Procedures and functions a) Write a Procedure on EMP Table, it should increase commission of an Employee. Emp. No. and Comm. are passed as parameters to the Called Procedure. If Commission is found to be Null, procedure should generate user defined Error Message. b) Write a Function which accepts Input as a number and prints whether it is EVEN or ODD. Relevant Theory / Literature Survey: (Brief Theory Expected) Procedures:- A procedure is a subprogram that performs a specific action. You write procedures using the syntax
PROCEDURE name [(parameter[, parameter, ...])] IS [local declarations] BEGIN executable statements [EXCEPTION exception handlers] END [name];

where parameter stands for the following syntax:
parameter_name [IN | OUT [NOCOPY] | IN OUT [NOCOPY]] datatype_name [{:= | DEFAULT} expression]

A procedure has two parts: the specification (spec for short) and the body. The procedure spec begins with the keyword PROCEDURE and ends with the procedure name or a parameter list. Parameter declarations are optional. Procedures that take no parameters are written without parentheses. The procedure body begins with the keyword IS and ends with the keyword END followed by an optional procedure name. The procedure body has three parts: a declarative part, an executable part, and an optional exception-handling part. The declarative part contains local declarations, which are placed between the keywords IS and BEGIN. The keyword DECLARE, which introduces declarations in an anonymous PL/SQL block, is not used. The executable part contains statements, which are placed between the keywords BEGIN and EXCEPTION (or END). At least one statement must appear in the executable part of a procedure. A procedure is called as a PL/SQL statement. Functions :- A function is a subprogram that computes a value. Functions and procedures are structured alike, except that functions have a RETURN clause. You write functions using the syntax
FUNCTION name [(parameter[, parameter, ...])] RETURN datatype IS [local declarations] BEGIN executable statements [EXCEPTION exception handlers] END [name];

18

RDBMS & VB MANUAL where parameter stands for the following syntax:
parameter_name [IN | OUT [NOCOPY] | IN OUT [NOCOPY]] datatype_name [{:= | DEFAULT} expression]

A function is called as part of an expression Design Analysis / Implementation Logic:
(Algorithm / Flow Chart / Pseudo Code / UML diagram / DFD as per requirement)

Testing:
(Input/ Output):

Conclusion: Studied procedures and functions in PL/SQL

19

RDBMS & VB MANUAL

Assignment No. 8
Title of Assignment: Create a Trigger that audits the operations of EMP Table Relevant Theory / Literature Survey: (Brief Theory Expected) Database Triggers :- Oracle allows you to define procedures that are implicitly executed when an INSERT, UPDATE, or DELETE statement is issued against the associated table. These procedures are called database triggers. Triggers are similar to stored procedures. A trigger stored in the database can include SQL and PL/SQL statements to run as a unit and can invoke stored procedures. However, procedures and triggers differ in the way that they are invoked. A procedure is explicitly run by a user, application, or trigger. Triggers are implicitly fired by Oracle when a triggering event occurs, no matter which user is connected or which application is being used. Parts of Triggers :- A trigger has three basic parts
• • •

a triggering event or statement a trigger restriction a trigger action

Triggering Event or Statement A triggering event or statement is the SQL statement that causes a trigger to be fired. A triggering event can be an INSERT, UPDATE, or DELETE statement on a table. Trigger Restriction A trigger restriction specifies a Boolean (logical) expression that must be TRUE for the trigger to fire. The trigger action is not executed if the trigger restriction evaluates to FALSE or UNKNOWN. Trigger Action A trigger action is the procedure (PL/SQL block) that contains the SQL statements and PL/SQL code to be executed when a triggering statement is issued and the trigger restriction evaluates to TRUE. Types of Triggers Row Triggers A row trigger is fired each time the table is affected by the triggering statement. Statement Triggers A statement trigger is fired once on behalf of the triggering statement, regardless of the number of rows in the table that the triggering statement affects (even if no rows are affected). BEFORE vs. AFTER Triggers When defining a trigger, you can specify the trigger timing . BEFORE Triggers BEFORE triggers execute the trigger action before the triggering statement. AFTER Triggers AFTER triggers execute the trigger action after the triggering 20

RDBMS & VB MANUAL statement is executed Design Analysis / Implementation Logic:
(Algorithm / Flow Chart / Pseudo Code / UML diagram / DFD as per requirement)

Testing:
(Input/ Output):

Conclusion: Studied and Implemented triggers.

21

RDBMS & VB MANUAL

Assignment No. 9
Title of Assignment: Write and Execute Embedded SQL Queries using C/C++ as a host language. Relevant Theory / Literature Survey: (Brief Theory Expected) Embedded SQL is a method of combining the computing power of a high-level language like C/C++ and the database manipulation capabilities of SQL. It allows you to execute any SQL statement from an application program. Oracle's embedded SQL environment is called Pro*C. A Pro*C program is compiled in two steps. First, the Pro*C precompiler recognizes the SQL statements embedded in the program, and replaces them with appropriate calls to the functions in the SQL runtime library. The output is pure C/C++ code with all the pure C/C++ portions intact. Then, a regular C/C++ compiler is used to compile the code and produces the executable. All SQL statements need to start with EXEC SQL and end with a semicolon ";". You can place the SQL statements anywhere within a C/C++ block, with the restriction that the declarative statements do not come after the executable statements. As an example:
{ int a; /* ... */ EXEC SQL SELECT salary INTO :a FROM Employee WHERE SSN=876543210; /* ... */ printf("The salary is %d\n", a); /* ... */ }

Design Analysis / Implementation Logic:
(Algorithm / Flow Chart / Pseudo Code / UML diagram / DFD as per requirement)

Testing:
(Input/ Output):

Conclusion: Studied the concept of Embedded SQL.

22

RDBMS & VB MANUAL

Assignment No. 10
Title of Assignment: Write and execute Dynamic SQL Query Relevant Theory / Literature Survey: (Brief Theory Expected) Some applications must accept (or build) and process a variety of SQL statements at run time. For example, a general-purpose report writer must build different SELECT statements for the various reports it generates. In this case, the statement's makeup is unknown until run time. Such statements can, and probably will, change from execution to execution. They are aptly called dynamic SQL statements. Unlike static SQL statements, dynamic SQL statements are not embedded in your source program. Instead, they are stored in character strings input to or built by the program at run time. They can be entered interactively or read from a file. Host programs that accept and process dynamically defined SQL statements are more versatile than plain embedded SQL programs. Dynamic SQL statements can be built interactively with input from users having little or no knowledge of SQL. However, some dynamic queries require complex coding, the use of special data structures, and more runtime processing When to Use Dynamic SQL In practice, static SQL will meet nearly all your programming needs. Use dynamic SQL only if you need its open-ended flexibility. Its use is suggested when one of the following items is unknown at precompile time:
• • • •

text of the SQL statement (commands, clauses, and so on) the number of host variables the datatypes of host variables references to database objects such as columns, indexes, sequences, tables, usernames, and views

To represent a dynamic SQL statement, a character string must contain the text of a valid SQL statement. How Dynamic SQL Statements Are Processed Typically, an application program prompts the user for the text of a SQL statement and the values of host variables used in the statement. Then Oracle parses the SQL statement. That is, Oracle examines the SQL statement to make sure it follows syntax rules and refers to valid database objects. Parsing also involves checking database access rights, reserving needed resources, and finding the optimal access path. Next, Oracle binds the host variables to the SQL statement. That is, Oracle gets the addresses of the host variables so that it can read or write their values. Then Oracle executes the SQL statement. That is, Oracle does what the SQL statement requested, such as deleting rows from a table. The SQL statement can be executed repeatedly using new values for the host variables. Design Analysis / Implementation Logic: (Algorithm / Flow Chart / Pseudo Code / UML diagram / DFD as per requirement) 23

RDBMS & VB MANUAL Testing:
(Input/ Output):

Conclusion: Studied concept of Dynamic SQL Query.

24

RDBMS & VB MANUAL

Assignment No. 11
Title of Assignment: Write a program in VB to generate Student Information using VB Controls. Relevant Theory / Literature Survey: (Brief Theory Expected) Visual Basic is an event driven programming language. The visual part refers to the method used to create the graphical user interface(GUI). In VISUAL BASIC, programming is done in a graphical environment. Because users may click on a certain object randomly, so each object has to be programmed independently to be able to response to those actions (events). Therefore, a VISUAL BASIC Program is made up of many subprograms, each has its own program codes, and each can be executed independently and at the same time each can be linked together in one way or another. There are three different editions of Visual Basic • The Learning Edition • The professional Edition • The Enterprise Edition Project types that VB supports are • Standard Windows EXE programs • ActiveX EXE files • ActiveX DLLs • ActiveX controls • Programs written by the Visual Basic Application Wizard • Data projects • VB Enterprise Edition controls The Project Explorer Window view major parts of your project . The Properties Window enables you to see and modify properties of VB objects. The Forms Window enables you to graphically design a form. The toolbox is made up of controls that are available to you to place on forms. Toolbox Controls are as follows Text Box Control :- To display or accept user input in the form of text. The Picture Box :- To display the graphic Label Box :- To display text that you don’t want the user to change. Option Button :- To display multiple choices which the user can choose only one option. Frame :- Allows you to create a graphical or functional grouping controls. List Box :- To display list of items from which the user can choose one Combo Box :- To choose an item from the list or enter a value in the text box. Data:- Provides access to databases through controls on your form. HScrollbar and VScrollbar :- For navigation. Command Button :- To carry out a command. Check Box :- To display multiple choices and user can choose more than one. The Drive , Directory and File List Control :- To display available Drive, Directories and files. The Line and Shape Controls :- Used to draw lines, squares, circles etc. The Image Control :- To display image. OLE( Object Linking and Embedding) :- To link your program to another object or program. Design Analysis / Implementation Logic: (Algorithm / Flow Chart / Pseudo Code / UML diagram / DFD as per requirement) Design interface to get the Students Information using different controls. Provide submit button , clear button and cancel button .Do the coding for clear and cancel button. 25

RDBMS & VB MANUAL Testing:
(Input/ Output):

Conclusion: The Interface for students information has been designed using different controls of VB.

26

RDBMS & VB MANUAL

Assignment No. 12
Title of Assignment: Write a program in VB to implement Scientific Calculator using Programming Constructs of VB. Relevant Theory / Literature Survey: (Brief Theory Expected) Control Array :- A control array is a dynamic array of controls of the same type declares at design time. A control array behaves the same as any regular array; the difference is that it contains control references, not data of some sort. Varibles in VB :- must follow several rules • The variable name must begin with a letter • The variable name can contain only A-Z,a-z,0-9 and underscore character. • The variable name can not exceed 255 characters in length. • The variable must be unique in the same scope. Data types :- Boolean , Byte, Currency, Date, Double, Integer, Long, Object , Single, String, Variant Subroutines :- is a named group of statements that can be invoked by using the sub procedure name. Functions :- similar to subroutines except they return a value. Design Analysis / Implementation Logic: (Algorithm / Flow Chart / Pseudo Code / UML diagram / DFD as per requirement) Implement the following functions of the calculator +, -, /, *, Mod, +/-, Sin, Cos, Tan, Backspace, clear, C, MC, MR, MS, M+, Pi, 1/x, sqrt, AND, OR, XOR, NOT, Hex, Oct, Bin Testing:
(Input/ Output):

Conclusion: A Mathematical Calculator in Scientific Mode has been designed and implemented using concept of Control array.

27

RDBMS & VB MANUAL

Assignment No. 13
Title of Assignment : Write a program to develop a Notepad Application using VB. Use concepts of Menus and Events Relevant Theory / Literature Survey: (Brief Theory Expected) 1. RichTextBox Control a. Description b. Design-Time Properties(General, Appearance, Color, Font, Picture) c. Run-time Operations Loading and Saving Files Changing character Attributes Changing Paragraph attributes Searching and Replacing text 2. Common Dialog Box Control a. Color Dialog b. Font Dialog c. Printer Dialog d. FileOpen Dialog e. FileSave Dialog f. Help Dialog 3. Menu Editor Design Analysis / Implementation Logic: (Algorithm / Flow Chart / Pseudo Code / UML diagram / DFD as per requirement) Implement the following Menus for the Notepad 1. File (New, Open, Save, Save As, Page Setup, Print, Exit) 2. Edit (Undo, cut, copy, paste, delete, Find, Find Next , Select All) 3. Format (Word wrap, Font, Color (Text, Background)) 4. Help (Help Topics) Testing:
(Input/ Output):

1. Create New Document with the name accepted in the Common Dialog Box (File-New Menu option ) 2. Save the document in particular format with appropriate name and extension. (File-Save Menu option) 3. Change the font, color, size and style of the selected Text (Format-Font Menu option) 4. Do Page Setup to set paper size to A4 and Page layout as Portrait (File-Page Setup Menu Option) 5. Get Help (Help Menu Option) Conclusion: Design and implementation of Notepad has been designed and implemented using Common Dialog Box Control, RichTextBox Control and Menu Editor

Assignment No. 14
28

RDBMS & VB MANUAL Title of Assignment: Build Simple Animation with Picture and Timer Controls. Relevant Theory / Literature Survey: The Objective of the assignment is to learn and implement the Picture Box and timer controls of VB.

Timer Control :
The Timer is the toolbox controls that are not visible at run time, which means that you can place it anywhere on the form. It only does one thing: it checks the system clock. It has no methods but two important properties. These are Enabled : This holds True or False. An enabled timer is able to carry out what you have coded in its Timer events, but a disabled timer cannot. Interval : This is measured in milliseconds. A value of 1000 represents 1000 milliseconds or 1 second. The timer only has an event, called the TIMER event. If the timer is enabled, when the time represented by its interval property has elapsed, it generates its own Timer events. For example an Interval value of 500 would call the timer event every half a second. The timer control function is below
Private Sub Timer1_Timer() '// this procedure is called End Sub

Picture Box :
It display graphics as bitmaps, icons, JPEGs and GIFs. If you want to move the graphic around the form, a picture box produces a smoother display. In addition you can create text and use graphics methods in a picture box at run time. The most important of picture box is that it acts as containers for other controls. Thus you can place a command button within a picture box. The following code demonstrates how to display a picture in a Picture Box control at run time. Picture1.Picture = LoadPicture(App.Path & "\somepicture.jpg")

29

RDBMS & VB MANUAL Design Analysis / Implementation Logic:
(Algorithm / Flow Chart / Pseudo Code / UML diagram / DFD as per requirement)

1. Start  Programs Microsoft Visual Studio 6  Microsoft Visual Basic 6.0. 2. After step1 we will get New Project window. 3. Select Standard EXE and click on the Open button. 4. We will get a canvas form where we can place our controls and codes. 5. From the left side tool bar select the timer control (by default timer name will be timer1) and place it on the canvas form. 6. After this select the picture control(by default picture box will be picture1) from the left side tool bar and place it on the canvas form. 7. Select the picture box on the form and from the picture box property box which is located on the right side change the AUTO SIZE property to TRUE and BORDER STYLE to NONE. 8. Place a command button on the Form. 9. Now write the program for the animation to happen. Please Note : To do this animation program we need a series / bunch of images. Testing: 1. We will execute the program by pressing the F5 key and will see that the desired animation is working as per the specified specifications. 2. If not then do the necessary modifications and re execute it to view the results. Conclusion: With the help of this program we have leant the concepts of timer, picture control and to use them in the programs.

Assignment No.15
30

RDBMS & VB MANUAL Title of Assignment: To build a program which will allow user to select a file in a particular directory on a particular drive .Use drive list box control, directory list control and file list control. Relevant Theory / Literature Survey: Usually we use the Common Dialogs File Open and File Save As to get file names and file paths from the user . But sometimes we require a program where we want to let the user select files but don’t want to use dialog boxes .Here we can use Visual Basic file controls : drive list box control, directory list control and file list control.These controls are intrinsic to VB(ie. They appear in the tool box when VB is started. The Drive List BOX Control – Selects the drive. We get the currently selected drive in a drive list box by using its Drive property , and when the user changes the drive in that control, a change event is generated. The Directory List Box Control – Displays directories as a hierarchical set of folders. The important property of the directory list box is the Path property ,which holds the path of the current directory . When the user changes the current path , a Change event is generated. The File List Box Control – Display the files in a directory as a list of names. The Path and FileName are the important properties of the File List Box. Design Analysis / Implementation Logic: Take the appropriate controls ie, a drive list box, Drive1; a directory list box,Dir1; filelist box, File1; a command button,Command1,which is labeled Display File; and a text box with its MultiLine property set to True and its Scrollbars property set to Both. When the user changes the drive, we pass that new drive to the directory list box as the new directoty in Drive_Change( ):: Sub Drive1_Change( ) Dir1.Path = Drive1.Drive End Sub When user changes the directory , we pass that new path to the file list box in Dir1_Change( ) Sub Dir1_Change ( ) File1.Path = Dir1.Path End Sub. When the user clicks the button ,we want to display the contents of the selected file in the text box.This is done in the command button’s Click event handler,Command1_Click ( ) 31

RDBMS & VB MANUAL We’ll also call the button’s Click event handler to let the user open a file by doubleclicking it in the file control. Sub File1_DblClick( ) Command1_Click End Sub When the user wants to open a file , we put together the file’s name and path. Sub Command1_Click ( ) Dim FileName As String On Error GoTo FileError If (Right$ (Dir1.Path , 1 ) = “\” ) Then FileName = File1.Path & File1.FileName Else FileName = File1.Path & “\” & File1.FileName End If . Open FileName For Input As #1 Text1.Text = Input$(LOF(1) , #1) Close #1 Exit Sub FileError: MsgBox “File Error !” End Sub

Testing: NA Conclusion: Thus a program is implemented which will allow user to select a file in a particular directory on a particular drive using drive list box control, directory list control and file list control of Visual Basic.

Assignment No. 16
32

RDBMS & VB MANUAL Title of Assignment: Design a multimedia player which can play movie and songs in standard formats. Relevant Theory / Literature Survey: (Brief Theory Expected) The objective of the assignment is to learn the Multimedia MCI control in VB. The Multimedia MCI Control This control in VB manages the recording and playback of multimedia files on Media Control Interface (MCI) devices. This control issues commands to devices like audio boards, MIDI sequencers, CD-ROM drives, audio CD players, videotape recorder/players and more. The multimedia control also lets you play WAV and MID sound files and display video files like AVI and MPG. The actual control displays a bar of buttons. The buttons are named Prev, Next, Play, Pause, Back, Step, Stop, Record, and Eject, in that order. Properties of the Control :• DeviceType property is used to set the type of device you want to work with. Different strings to set DeviceType property are AVIVideo , CDAudio, DAT, DigitalVideo , VCR, Videodisc, WaveAudio and so on • • • Command property to Open, Close, Play, Pause etc. the device. TimeFormat property to specify timing information. FileName property to specify which file you want to use with a multimedia control. You can keep track of the multimedia control through two events, the Done event and the StatusUpdate event. The Done event is fired to indicate that various multimedia operations are completed (if you have set the control’s Notify property to True), and the StatusUpdate property occurs when the status of the control changes (such as when the user clicks the Play button and the controls begins playback). Design Analysis / Implementation Logic:
(Algorithm / Flow Chart / Pseudo Code / UML diagram / DFD as per requirement)

To play sound using multimedia control first add control to program using following steps :1. Select the Project | Components menu item. 2. Click the Control tab in the Components dialog box that opens. 3. Select the entry labeled Microsoft Multimedia Control, and click on OK to close the Components dialog box. 4. Now your VB toolbox shows the control , just drag and drop it in your program. 5. Set the control’s DeviceType , FileName , and TimeFormat properties as needed 6. Add PictureBox control Picture1 in your program. 33

RDBMS & VB MANUAL 7. Now to open the file , making the buttons of the multimedia control, MMControl1, active and connect the multimedia control to the picture box Picture1 by adding following code on Form_load event. Private Sub Form_Load() MMControl1.Notify = False MMControl1.Wait = True MMControl1.Shareable = False MMControl1.FileName = "C:\WINDOWS\clock.avi" MMControl1.hWndDisplay = Picture1.hWnd MMControl1.Command = "Open" End Sub Now run the program , click the buttons in the multimedia control , you can play , stop and restart the AVI files as you like. The animation appears in the picture box Picture1 Testing:
(Input/ Output):We

will execute the program and can play any song or video .

Conclusion: With the help of this program we have studied how to use Multimedia control to play song or video.

Assignment No. 17
Title of Assignment: Create a database using MS-ACCESS and perform different data handling operations using Database Control of VB. 34

RDBMS & VB MANUAL Relevant Theory / Literature Survey: (Brief Theory Expected) 1. Difference in ADODC and ADODB 2.What is DAO, RDO, ADO? 3.Design-time properties of ADODC with MS Access 4. Setting properties of ADODC programmatically Design Analysis / Implementation Logic:
(Algorithm / Flow Chart / Pseudo Code / UML diagram / DFD as per requirement)

Create a Data Entry form on Customer tablewith following command buttons Add, Modify, Delete, Update, Exit and Navigate (First, Next, Previous, Last) Testing:
(Input/ Output):

Conclusion: Thus we have created and performed database operations using Database Control of VB.

Assignment No. 18
Title of Assignment: Perform Packaging and Deployment for a VB Application 35

RDBMS & VB MANUAL Relevant Theory / Literature Survey: (Brief Theory Expected) After you have built your application and ready to distribute it, you must have a way of getting the application installed on another computers. You can use the Package and Deployment Wizard that comes with Visual Basic. This tool quickly and easily creates installation programs based on your answers to some options presented by the wizard. Design Analysis / Implementation Logic: (Algorithm / Flow Chart / Pseudo Code / UML diagram / DFD as per requirement) Packaging steps :Click Start -> program ->VB studio ->Microsoft VB tool -> Packaging and deployment Wizard Select Project -> Select Package Specify Package script Select Standard set up package. Give package folder. Select single cab Packaging Report – Take print out Deployment steps :Click Start -> Program-> Startup click on setup. Testing:
(Input/ Output):

Conclusion: Performed Packaging and Deployment for a VB Application .

Assignment No. 19
Title of Assignment : Study Assignment on COBOL Programming 36

RDBMS & VB MANUAL Relevant Theory / Literature Survey: (Brief Theory Expected) 1. What is COBOL? COBOL basics 2. The structure of COBOL programs 3. The Four Divisions 4. Categories of COBOL data Declaring Data-Items in COBOL 7. Group and Elementary data-items 8. Basic User Input and Output 1. MOVE verb 2. Arithmatic using COBOL Design Analysis / Implementation Logic:
(Algorithm / Flow Chart / Pseudo Code / UML diagram / DFD as per requirement)

1. Write a Program to accept a matrix, display, and provide a menu with options as follows 1. To find minimum element in the matrix 2. To find maximum element in the matrix 3. Continue? 2. Write a Program for File handling with following options 1. Open, 2. Close, 3. Add record 4. Read record Testing:
(Input/ Output)

Conclusion: Thus we have studied and understood the use of COBOL.

37

RDBMS & VB MANUAL

38

RDBMS & VB MANUAL

39

RDBMS & VB MANUAL

40

RDBMS & VB MANUAL

41

Sign up to vote on this title
UsefulNot useful