You are on page 1of 9

VISUAL BASIC .

NET

(VB.NET) is an object oriented computer programming language implemented on the .NET


Framework. Although it is an evolution of classic Visual Basic language, it is not backwards
compatible with VB6, and any code written in the old version does not compile under VB.NET.
Like all other .NET languages, VB.NET has complete support for object -oriented concepts.
Everything in VB.NET is an object, including all of the primitive types (Short, Integer, Long,
String, Boolean, etc.) and user - defined types, events, and even assemblies. All objects inherits
from the base class Object.

VB.NET is implemented by Microsoft's .NET framework. Therefore, it has full access to all the
libraries in the .Net Framework. It's also possible to run VB.NET programs on Mono, the open -
source alternative to .NET, not only under Windows, but even Linux or Mac OSX.

The following reasons make VB.Net a widely used professional language:

 Modern, general purpose.

 Object oriented.

 Component oriented.

 Easy to learn.

 Structured language.

 It produces efficient programs.

 It can be compiled on a variety of computer platforms.

 Part of .Net Framework.

.Net Framework

The .Net framework is a revolutionary platform that helps you to write the following types of
applications:

 Windows applications

 Web applications

 Web services

The .Net framework applications are multi – platform applications. The framework has been
designed in such a way that it can be used from any of the following languages: Visual Basic,
C#, C++, Jscript, and COBOL, etc.All these languages can access the framework as well as
communicate with each other.

The .Net framework consists of an enormous library of codes used by the client languages like
VB.Net. These languages use object - oriented methodology.

Following are some of the components of the .Net framework:

 Common Language Runtime (CLR)

 The .Net Framework Class Library

 Common Language Specification

 Common Type System

 Metadata and Assemblies

 Windows Forms

 ASP.Net and ASP.Net AJAX

 ADO.Net

Integrated Development Environment (IDE) For VB.Net

Microsoft provides the following development tools for VB.Net programming:

 Visual Studio 2010 (VS)

 Visual Basic 2010 Express (VBE)

 Visual Web Developer

The last two are free. Using these tools, you can write all kinds of VB.Net programs from simple
command - line applications to more complex applications. Visual Basic Express and Visual
Web Developer Express edition are trimmed down versions of Visual Studio and has the same
look and feel. They retain most features of Visual Studio. In this tutorial, we have used Visual
Basic 2010 Express and Visual Web Developer (for the web programming chapter). You can
download it from here. It gets automatically Istalled in your machine. Please note that you need
an active internet connection for installing the express edition.

Structured Query Language

Introduction to SQL
SQL is nonprocedural language that provides database access. It is nonprocedural in that users
describe in SQL what they want done, and the SQL language compiler automatically generates a
procedure to navigate the database and perform the desired task.

Oracle SQL includes many extensions to the ANSI/ISO standard SQL language, and Oracle tools
and applications provide additional statements. The Oracle tools SQL*Plus and Oracle
Enterprise Manager let you run any ANSI/ISO standard SQL statement against an Oracle
database, as well as additional statements or functions that are available for those tools.

Although some Oracle tools and applications simplify or mask SQL use, all database operations
are performed using SQL. Any other data access method circumvents the security built into
Oracle Database and potentially compromises data security and integrity.

SQL Statements:

All operations performed on the information in Oracle Database are run using SQL statements. A
statement consists of identifiers, parameters, variables, names, datatypes, and SQL reserved
words. SQL reserved words have special meaning in SQL and cannot be used for any other
purpose. For example, SELECT and UPDATE are reserved words and cannot be used as table
names.

A SQL statement is a computer program or instruction. The statement must be the equivalent of
a complete SQL sentence, such as:

SELECT last_name, department_id FROM employees;

Only complete SQL statements can be run. A fragment such as the following generates an error
indicating that more text is required before a SQL statement can run:

SELECT last_name;

SQL statements are divided into the following categories:

 Data Manipulation Language Statements

 Data Definition Language Statements

 Transaction Control Statements

 Session Control Statements

 System Control Statements

 Embedded SQL Statements


Data Manipulation Language Statements

Data manipulation language (DML) statements query or manipulate data in existing schema
objects. They enable you to:

 Retrieve or fetch data from one or more tables or views (); fetches can be scrollable
(see "Scrollable Cursors").

 Add new rows of data into a table or view (INSERT).

 Change column values in existing rows of a table or view (UPDATE).

 Update or insert rows conditionally into a table or view (MERGE).

 Remove rows from tables or views (DELETE).

 View the execution plan for a SQL statement (EXPLAIN PLAN).

 Lock a table or view, temporarily limiting other users' access (LOCK TABLE).

DML statements are the most frequently used SQL statements. Some examples of DML
statements are:

SELECT last_name, manager_id, commission_pct + salary FROM employees;

INSERT INTO employees VALUES(1234, ‘DAVIS’, ‘SALESMAN’, 7698,

’14-FEB-1988’,1600,500,30);

DELETE FROM employees WHERE last_name IN (‘WARD’,’JONES’);

DML Error Logging

When a DML statement encounters an error, the statement can continue processing while the
error code and the associated error message text is logged to an error logging table. This is
particularly helpful to long-running, bulk DML statements. After the DML operation completes,
you can check the error logging table to correct rows with errors.

New syntax is added to the DML statements to provide the name of the error logging table, a
statement tag, and a reject limit. The reject limit determines whether the statement should be
aborted. For parallel DML operations, the reject limit is applied for each slave. The only values
for the reject limit that are precisely enforced on parallel operations are zero and unlimited.

With data conversion errors, Oracle Database tries to provide a meaningful value to log for the
column. For example, it could log the value of the first operand to the conversion operator that
failed. If a value cannot be derived, then NULL is logged for the column.
Data Definition Language Statements

Data definition language (DDL) statements define, alter the structure of, and drop schema
objects. DDL statements enable you to:

 Create, alter, and drop schema objects and other database structures, including the
database itself and database users (CREATE, ALTER, DROP).

 Change the names of schema objects (RENAME).

 Delete all the data in schema objects without removing the objects' structure
(TRUNCATE).

 Grant and revoke privileges and roles (GRANT, REVOKE).

 Turn auditing options on and off (AUDIT, NOAUDIT).

 Add a comment to the data dictionary (COMMENT).

DDL statements implicitly commit the preceding commands and start new transactions. Some
examples of DDL statements are:

CREATE TABLE plants

(COMMON_NAME VARCHAR2 (15), LATIN_NAME VARCHAR2 (40));

DROP TABLE plants;

GRANT SELECT ON employees TO scott;

REVOKE DELETE ON employees FROM scott;

Transaction Control Statements

Transaction control statements manage the changes made by DML statements and group DML
statements into transactions. They enable you to:

 Make changes to a transaction permanent (COMMIT).


 Undo the changes in a transaction, since the transaction started or since a savepoint
(ROLLBACK).

 Set a point to which you can roll back (SAVEPOINT).

 Establish properties for a transaction (SET TRANSACTION).

Session Control Statements

Session control statements manage the properties of a particular user's session. For example, they
enable you to:

 Alter the current session by performing a specialized function, such as enabling and
disabling the SQL trace facility (ALTERSESSION).

 Enable and disable roles (groups of privileges) for the current session (SET ROLE).

System Control Statements

System control statements change the properties of the Oracle database instance. The only
system control statement is ALTERSYSTEM. It enables you to change settings (such as the
minimum number of shared servers), terminate a session, and perform other tasks.

Embedded SQL Statements

Embedded SQL statements incorporate DDL, DML, and transaction control statements within a
procedural language program. They are used with the Oracle precompilers. Embedded SQL
statements enable you to:

 Define, allocate, and release cursors (DECLARE CURSOR, OPEN, CLOSE).

 Specify a database and connect to Oracle Database (DECLARE


DATABASE, CONNECT).

 Assign variable names (DECLARE STATEMENT).

 Initialize descriptors (DESCRIBE).

 Specify how error and warning conditions are handled (WHENEVER).

 Parse and run SQL statements (PREPARE, EXECUTE, EXECUTE IMMEDIATE).

 Retrieve data from the database (FETCH).


Shared SQL Areas

Oracle Database automatically notices when applications send similar SQL statements to the
database. The SQL area used to process the first occurrence of the statement is shared—that is,
used for processing subsequent occurrences of that same statement. Therefore, only one shared
SQL area exists for a unique statement. Because shared SQL areas are shared memory areas, any
Oracle Database process can use a shared SQL area. The sharing of SQL areas reduces memory
use on the database server, thereby increasing system throughput.

In evaluating whether statements are similar or identical, Oracle Database considers SQL
statements issued directly by users and applications as well as recursive SQL statements issued
internally by a DDL statement.

Parsing

Parsing is one stage in the processing of a SQL statement. When an application issues a SQL
statement, the application makes a parse call to Oracle Database. During the parse call, Oracle
Database:

 Checks the statement for syntactic and semantic validity.

 Determines whether the process issuing the statement has privileges to run it.

 Allocates a private SQL area for the statement.

Oracle Database also determines whether or not there is an existing shared SQL area containing
the parsed representation of the statement in the library cache. If so, the user process uses this
parsed representation and runs the statement immediately. If not, Oracle Database generates the
parsed representation of the statement, and the user process allocates a shared SQL area for the
statement in the library cache and stores its parsed representation there.

Note the difference between an application making a parse call for a SQL statement and Oracle
Database actually parsing the statement.

 A parse call by the application associates a SQL statement with a private SQL area. After
a statement has been associated with a private SQL area, it can be run repeatedly without
your application making a parse call.

 A parse operation by Oracle Database allocates a shared SQL area for a SQL statement.
Once a shared SQL area has been allocated for a statement, it can be run repeatedly
without being reparsed.

Both parse calls and parsing can be expensive relative to execution, so perform them as seldom
as possible.
See Also:

"Overview of PL/SQL"

Although parsing a SQL statement validates that statement, parsing only identifies errors that can
be found before statement execution. Thus, some errors cannot be caught by parsing. For
example, errors in data conversion or errors in data (such as an attempt to enter duplicate values
in a primary key) and deadlocks are all errors or situations that can be encountered and reported
only during the execution stage.

Query Processing

Queries are different from other types of SQL statements because, if successful, they return data
as results. Whereas other statements simply return success or failure, a query can return one row
or thousands of rows. The results of a query are alwaysin tabular format, and the rows of the
result are fetched (retrieved), either a row at a time or in groups.

Several issues relate only to query processing. Queries include not only
explicit SELECT statements but also the implicit queries(subqueries) in other SQL statements.
For example, each of the following statements requires a query as a part of its execution:

INSERT INTO table SELECT...

UPDATE table SET x = y WHERE...

DELETE FROM table WHERE...

CREATE table AS SELECT...

In particular, queries:

 Require read consistency

 Can use temporary segments for intermediate processing

 Can require the describe, define, and fetch stages of SQL statement processing.

SQL Processing

This section introduces the basics of SQL processing. It starts with a flowchart of typical SQL
statement execution which generally covers most types of SQL statements. followed by a general
description of the stages of SQL statement processing, and then a section indicating how the
flowchart and description may differ for different types of SQL statements.

Topics include:

 flowchart of SQL Statement Execution

 Description of SQL Statement Processing

 Processing Other Types of SQL Statements

flowchart of SQL Statement Execution

Figure 24-1 outlines the stages commonly used to process and run a SQL statement. In some
cases, Oracle Database can run these stages in a slightly different order. For example,
the DEFINE stage could occur just before the FETCH stage, depending on how you wrote your
code.

You might also like