Oracle Demo File

download Oracle Demo File

of 61

Transcript of Oracle Demo File

  • 7/29/2019 Oracle Demo File

    1/61

    Oracle

    Introduction to Oracle

    The oracle corporation is the worlds leading supplier of software for

    information management and worlds second largest independent software

    company. Oracle is the top selling multi user RDBMS. Oracle application

    covers business intelligence, ecommerce, financials, human resources,

    manufacturing, mobile, project, and sales.

    Features of Oracle

    Client/Server Architecture

    Large database and space management

    Concurrent Processing

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    1

  • 7/29/2019 Oracle Demo File

    2/61

    High transaction processing performance

    High Availability

    Controlled availability

    Openness industry standards

    Manageable security

    Database enforced integrity

    Distributed system

    Portability

    Compatibility

    Replicated environment

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    2

  • 7/29/2019 Oracle Demo File

    3/61

    SQL

    Introduction to SQL

    SQL stands for Structured Query Language. SQL is a simple and powerful

    language used to create access and manipulate data and structure in the

    database. SQL is like plain English, which is easy to understand and to write.

    The history of SQL begins in an IBM laboratory in San Jose, California, where

    SQL was developed in the late 1970s. The initials stand for Structured Query

    Language, and the language itself is often referred to as "sequel." It was

    originally developed for IBM's DB2 product (a relational database management

    system, or RDBMS, that can still be bought today for various platforms and

    environments). In fact, SQL makes an RDBMS possible.

    SQL is a nonprocedural language, in contrast to the

    procedural or third-generation languages (3GLs) such as COBOL and C that

    had been created up to that time. SQL is the de facto standard language used to

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    3

  • 7/29/2019 Oracle Demo File

    4/61

    manipulate and retrieve data from these relational databases. SQL enables a

    programmer or database administrator to do the following:

    Modify a database's structure

    Change system security settings

    Add user permissions on databases or tables

    Query a database for information

    Update the contents of a database

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    4

  • 7/29/2019 Oracle Demo File

    5/61

    Types of SQL statements

    There are three types of SQL statements:-

    1. Data Definition Language statements: - DDL statements are used to define,

    alter or drop database objects. The following table gives an overview about

    DDL statements.

    Sr.No Need and Usages the SQL DDL statement

    1. Create schema objects create

    2. Alter schema objects alter

    3. Delete schema objects delete

    4. Rename schema objects rename

    5. Grant and take away privileges grant, revoke

    And rights

    6. Add a comment to the data

    Dictionary comment

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    5

  • 7/29/2019 Oracle Demo File

    6/61

    2. Data Manipulation Language statements: - Once the tables have been

    created, the DML statements enable users to query or manipulate data in

    existing schemas objects. DML statements are normally the most frequently

    used commands. The following table gives an overview about DML statements:

    Sr.No Need and Usages The SQL DML statement

    1. Remove rows from tables or delete

    Views

    2. Add new rows of data into insert

    Table or view

    3. Retrieve data from one or more select

    Tables

    4 Change column values in existing update

    Rows of a table or view

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    6

  • 7/29/2019 Oracle Demo File

    7/61

    3. Transaction Control Language statements: - TCL statements manage the

    Changes made by DML statements and group DML statements into transaction.

    The Following table gives an overview about TCL

    Sr.No Need and Usages The SQL TCL statement

    1. Make a transaction changes commit

    Permanent

    2. Undo changes in a transaction rollback

    Either since the transaction started

    Or since a savepoint

    3. Set point to which transaction can be savepoint

    Rolled back

    4. Establish properties for a transaction set transaction

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    7

  • 7/29/2019 Oracle Demo File

    8/61

    Data Types

    The information in a database is maintained in the form of table and each table

    consist of rows and columns, which store data and therefore this data must have

    some data type i.e. the type of data, which is stored in a table. The different data

    types available in oracle are:

    Data Types Description

    Vachar2 Contains variable length text string of up to

    2000 bytes

    Char Contains fixed text strings of up to 255

    bytes

    Number Contains numeric dataDate Contains date data

    Raw Contains binary data up to 255 bytes

    Long Contains text data of up to 2gigabytes

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    8

  • 7/29/2019 Oracle Demo File

    9/61

    Rules for SQL

    SQL statements may be on one or many lines.

    Command words cannot be split across lines.

    A; is used to end of SQL statements.

    Identifier can contain up to 30 characters and must start with an alphabetic

    character.

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    9

  • 7/29/2019 Oracle Demo File

    10/61

    The basic Select statements

    The SELECT statement is the most commonly used statement in SQL and it is

    used to retrieve information already stored in the database. To retrieve data you

    can either select all the column values or name specific columns in the

    SELECT clause to retrieve data.

    Selecting all columns

    Selecting specific columns

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    10

  • 7/29/2019 Oracle Demo File

    11/61

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    11

  • 7/29/2019 Oracle Demo File

    12/61

    Using arithmetic operators

    Oracle allows arithmetic operators to be used while viewing records from a

    table or while performing data manipulation operations such as insert, update

    and delete. These are:-

    1. + Addition

    2. - Subtraction

    3. / Division

    4. * Multiplication

    5. ** Exponentiation

    6. ( ) Enclosed operation

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    12

  • 7/29/2019 Oracle Demo File

    13/61

    Using column aliases

    Column aliases are used to rename column headings.

    Using concatenation operator

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    13

  • 7/29/2019 Oracle Demo File

    14/61

    We can link columns to other columns, arithmetic expressions, or constant

    values to create a character expression by using the concatenation operator.

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    14

  • 7/29/2019 Oracle Demo File

    15/61

    Eliminating duplicate rows

    To eliminate duplicate rows in the result, include the distinct keyword in the

    select clause immediately after the select keyword

    Limiting rows using a selection

    You can restrict the rows returned from the query by using the where clause. A

    where clause contains a condition that must be met, and it directly follows the

    from clause. If the condition is true the row meeting the condition is returned.

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    15

  • 7/29/2019 Oracle Demo File

    16/61

    Using Between operator

    In order to select data that is within a range of values, the BETWEEN operator

    is used. The BETWEEN operator allows the selection of rows that contain

    values within specific lower and upper limit. The range coded after the word

    BETWEEN is inclusive. The owner value must be coded first. The two values n

    between the range must be linked with the keyword AND. A BETWEEN

    operator can be used with both character and numeric data types. However one

    cannot mix the data type i.e. the lower value of a range of values from character

    column and the other from numeric column.

    Using the IN condition

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    16

  • 7/29/2019 Oracle Demo File

    17/61

    Pattern Matching

    The character pattern-matching operation is referred to as a wildcard search.

    You can select rows that match a character pattern using the like condition. The

    character pattern matching operation is referred to as a wildcard search. Two

    symbols can be used to construct the search string.

    % Represents any sequence of zero or more characters.

    _ Represents any single character

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    17

  • 7/29/2019 Oracle Demo File

    18/61

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    18

  • 7/29/2019 Oracle Demo File

    19/61

    Using the NULL condition

    The null condition includes the is null condition and the is not null condition.

    The is null condition tests for nulls. A null value means the value is

    unavailable, unassigned, unknown or inapplicable. Therefore, you can not test

    with = because a null cannot be equal or unequal to any value.

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    19

  • 7/29/2019 Oracle Demo File

    20/61

    Using the logical operators

    Using the AND operator: -Returns true if both component conditions are true.

    Using the OR operator: -Returns true if either component condition is true.

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    20

  • 7/29/2019 Oracle Demo File

    21/61

    Sorting rows

    The order of rows returned in a query is undefined. The order by clause can be

    used to sort the rows. If you use the order by clause it must be the last clause of

    the sql statement. You can specify an expression, or an alias or column position

    as the sort condition.

    In ascending order

    In descending order

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    21

  • 7/29/2019 Oracle Demo File

    22/61

    Joining two tables

    When data from more than one table in the database is required, a join

    condition is used. Rows in one table can be joined to rows in another table

    according to common values existing in corresponding columns, that is, usually

    primary and foreign key columns. To display data from two or more related

    tables, write a simple join condition in the WHERE clause.

    In the syntax:

    Table1.column denotes the table and column from which data is retrieved

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    22

  • 7/29/2019 Oracle Demo File

    23/61

    Table1.column1= is the condition that join the tables together

    Table2.column2

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    23

  • 7/29/2019 Oracle Demo File

    24/61

    Using group functions

    Group functions operate on set of rows to give one result per set.

    MAX Function

    MIN Function

    COUNT Function

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    24

  • 7/29/2019 Oracle Demo File

    25/61

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    25

  • 7/29/2019 Oracle Demo File

    26/61

    Using AVG Function

    Using SUM Function

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    26

  • 7/29/2019 Oracle Demo File

    27/61

    The Having clause

    You use the having clause to specify which groups are to be displayed, and

    thus, you further restrict the groups on the basic of aggregate information.

    In the syntax:

    Group condition: - restricts the groups of rows returned to those groups for

    which the specified condition is true

    The Oracle server performs the following steps when you use the HAVING

    clause:

    1. Rows are grouped.

    2. The group function is applied to the group.

    3. The groups that match the criteria in the HAVING clause are displayed.

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    27

  • 7/29/2019 Oracle Demo File

    28/61

    Using Sub queries

    A sub query is a select statement that is embedded in a clause of another select

    statement. You can build powerful statement out of simple ones by using sub

    queries. They can be very useful when you need to select rows from a table

    with a condition that depends on the data in the table itself.

    You can place the sub query in a number of SQL clauses

    1. The WHERE clause

    2. The HAVING clause

    3. The FROM clause

    In the syntax

    Operator includes a comparison condition such as >, =, or IN

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    28

  • 7/29/2019 Oracle Demo File

    29/61

    Creating and managing tables

    Create tables to store data by executing the SQL create table statement. To

    create a table a user must have create table privilege and a storage area in which

    to create objects.

    Creating table

    Confirming table creation

    Creating a table using a sub query

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    29

  • 7/29/2019 Oracle Demo File

    30/61

    Alter Table statement

    After we create a table, we may need to change the table structure because; you

    omitted a column, your column definitions need to be changed, or you need to

    remove columns. You can do this by using the alter table statement.

    Adding a column

    Modifying a column

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    30

  • 7/29/2019 Oracle Demo File

    31/61

    Dropping Tables

    The drop table statement removes the definition of an oracle table. When you

    drop a table, the database loses all the data in the table and all the indexes

    associated with it.

    All data is deleted from the table.

    Any views and synonyms remains but are invalid.

    Any pending transactions are committed

    .

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    31

  • 7/29/2019 Oracle Demo File

    32/61

    Inserting data into a table

    You can add new rows to a table by issuing the insert statement. Because you

    can insert a new row that contains values for each column, the column list is not

    required in the insert clause. However if you do not use the column list the

    values must be listed according to the default order of the columns in the table

    and a value must be provided for each column.

    Specifying data for all columns

    Specifying data for selected columns

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    32

  • 7/29/2019 Oracle Demo File

    33/61

    Updating data

    We can modify existing rows by using the update statement. The update

    statement modifies specific rows if the where clause is specified.

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    33

  • 7/29/2019 Oracle Demo File

    34/61

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    34

  • 7/29/2019 Oracle Demo File

    35/61

    Deleting rows

    We can remove existing rows by using the delete statement. We can delete

    specific rows by using the where clause in the delete statement.

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    35

  • 7/29/2019 Oracle Demo File

    36/61

  • 7/29/2019 Oracle Demo File

    37/61

    Primary key: - A primary key constraint creates a primary key for the table. Only

    one primary key can be created for each table. The primary key constraint is a

    column that uniquely identifies each row in a table. A primary key column can not

    contain a null value.

    Foreign key: - The foreign key constraint designates a column as a foreign key and

    establishes a relationship between a primary key or a unique key in the same table or

    a different table.

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    37

  • 7/29/2019 Oracle Demo File

    38/61

    Check: - Defines a condition that each row must satisfy

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    38

  • 7/29/2019 Oracle Demo File

    39/61

    Views

    A view is a virtual or logical table that allows the viewing or manipulating the

    contents of one or more tables. Views do not really contain or store data, but

    they take data from the tables on which they are based, called base tables.

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    39

  • 7/29/2019 Oracle Demo File

    40/61

    Sequences

    Oracle provides an object called a sequence that can generate unique numeric

    value. If the value entered in a column is computer generated it will always

    fulfill the unique constraint and the row will always be accepted for storage.

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    40

  • 7/29/2019 Oracle Demo File

    41/61

    PL/SQL

    Introduction to PL/SQL

    PL/SQL is a procedure language that oracle developed as an extension to

    standard SQL in order to provide a way to execute procedure logic on the

    database. PL/SQL provide a mechanism for developer to add a procedure

    component at the server level PL/SQL is block structure language A PL/SQL

    block is a syntactically unit that might contain programmer code , variable

    declaration , error handler , procedure , function and even other PL/SQL block

    Syntax for PL/SQL block:

    Declare

    Variable_declarations

    Begin

    Program_code

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    41

  • 7/29/2019 Oracle Demo File

    42/61

    End;

    In this syntax variable declaration are any variable that might want to define

    cursor definition and nested PL/SQL procedure and function are also define

    here program code refer to the PL/SQL statement that make up the block.

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    42

  • 7/29/2019 Oracle Demo File

    43/61

    Advantage of PL/ SQL

    1. PL/SQL is a development tool that only not supports SQL data

    manipulation but also provides facility of conditional checking, branching

    and looping.

    2. PL/SQL sends an entire block of SQL statement to the oracle engine all in

    one go. Communication between the program block and oracle engine

    reduces considerably, reduces network traffic since the oracle engine got

    the SQL statement as a single block. It processes this code much faster

    than if it got once as one sentence at a time

    3. PL/SQL also permits dealing with error as required and facilitates

    displaying user friendly message when errors are encountered

    4. Via PL/SQL all sort of calculation can be done quickly and efficiently

    without the use oracle engine. This considerably improve transaction

    performance

    5. Applications written in PL/SQL are portable to any computer, hardware

    and operating system where as oracle is operational.

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    43

  • 7/29/2019 Oracle Demo File

    44/61

    Programs

    Program to calculate sum of two numbers

    Program to find greater of two numbers

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    44

  • 7/29/2019 Oracle Demo File

    45/61

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    45

  • 7/29/2019 Oracle Demo File

    46/61

    Program to find factorial of a given number

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    46

  • 7/29/2019 Oracle Demo File

    47/61

    Program to print Fibonacci series

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    47

  • 7/29/2019 Oracle Demo File

    48/61

    Procedures and Functions

    A procedure or function is a logically grouped set of SQL and PL statement that

    performs a specific task. A procedure and function is a named PL/SQL ode

    block that has been complied and stored in one of the oracle engine system

    table .procedure and function are made up of three parts : -

    1. Declarative part

    2. Executable part

    3. An optional exception handling part

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    48

  • 7/29/2019 Oracle Demo File

    49/61

  • 7/29/2019 Oracle Demo File

    50/61

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    50

  • 7/29/2019 Oracle Demo File

    51/61

    Functions

    Using local function

    Using stored function

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    51

  • 7/29/2019 Oracle Demo File

    52/61

    Cursors

    The oracle engine uses a work area for its internal processing in order to

    execute an SQL statement this work area is private to SQL operation and is

    called cursor

    Types of cursors

    Implicit cursor: - The oracle engine implicitly opens a cursor on the server to

    process each SQL statement. Since the implicit cursor is opened and managed

    by oracle server internally the function of reversing an area in memory,

    populating this area with appropriate data, processing the data in memory area,

    releasing the memory area when the processing is complete is taken care of by

    the oracle engine

    Explicit cursor: - When individual record in a table have to a process inside a

    PL/SQL block a cursor is used this cursor will be declared and mapped to an

    SQL query in declare section of the PLSQL block and used within its

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    52

  • 7/29/2019 Oracle Demo File

    53/61

    executable section. A cursor thus created and used is known as an explicit

    cursor

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    53

  • 7/29/2019 Oracle Demo File

    54/61

    Program to demonstrate implicit cursors

    Explicit cursor management

    This step involved in using an explicit cursor and manipulating data

    1. Declare a cursor mapped to a SQL select statement that retrieves data for

    processing

    2. Open the cursor

    3. Fetch data from the cursor one row at a time into memory variables

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    54

  • 7/29/2019 Oracle Demo File

    55/61

    4. Process the data held in the memory variables as required using a loop

    5. Exit from the loop after processing is complete

    6. Close the cursor

    Program to demonstrate implicit cursors

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    55

  • 7/29/2019 Oracle Demo File

    56/61

    Triggers

    Database trigger are data base object that are stored on the server. The oracle

    engine allows the definition of procedure that are implicitly executed when an

    insert, update or delete is issued against the table these procedure are called

    database trigger These data base object consist of the following distinct section

    1. A named data base event

    2. A PL/SQL block that executes when the event occurs

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    56

  • 7/29/2019 Oracle Demo File

    57/61

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    57

  • 7/29/2019 Oracle Demo File

    58/61

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    58

  • 7/29/2019 Oracle Demo File

    59/61

    Packages

    A package is an oracle object, which holds other objects with in it. Objects

    commonly held with in a package are procedures, functions, variables,

    constants, cursors and exception handlers. Package can contain PL/SQL block

    of code, which has been written to perform some process. PLSQL block of

    code do not require any kind of input from other PLSQL block of code. A

    package has two components. A specification and a body. A package

    specification declares the types, memory variables, constants, exceptions,

    cursors and sub programs that are available for use. A package body fully

    defines cursors, functions, procedures and thus implements the specification

    Creating package specification

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    59

  • 7/29/2019 Oracle Demo File

    60/61

    Creating package body

    Using packages

    It is only meant for Demo of Practical file of MCA-2nd Year (3rd Semester) Students. Nobody will

    copy it.

    Verified By: Rajan Manro

    For any query contact at: [email protected]

    60

  • 7/29/2019 Oracle Demo File

    61/61

    61