Beruflich Dokumente
Kultur Dokumente
VELMURUGAN C
______________________________________________________________
Registration No.
531210112
______________________________________________________________
Learning Center
2527
______________________________________________________________
Course/Program
BCA
______________________________________________________________
Semester
IV Semester
______________________________________________________________
Subject Code
BC0050
______________________________________________________________
Subject Title
Date of Submission
26.02.2014
______________________________________________________________
Marks Awarded
:
______________________________________________________________
_________________________________________________
_______________________________________________
Signature of Evaluator
SMU
_________________________________________
[<Block header>]
[declare
<Constants>
<Variables>
<Cursors>
<User defined exceptions>]
begin
<PL/SQL statements>
[exception
<Exception handling>]
end;
Instead of specifying a data type, one can also refer to the data type of a
table column. For example, EMP.Empno%TYPE refers to the data type of
the column Empno in the relation EMP. Instead of a single variable, a
record can be declared that can store a complete tuple from a given table
(or query result). For example, the data type DEPT%ROWTYPE specifies a
record suitable to store all attribute values of a complete row from the
table DEPT. Such records are typically used in combination with a cursor. A
field in a record can be accessed using <record name>.<column name>,
for example, DEPT.Deptno. A cursor declaration specifies a set of tuples
(as a query result) such that the tuples can be processed in a tupleoriented way (i.e., one tuple at a time) using the fetch statement.
A trigger is a data base object, like a table or an index. When you define a
trigger, it becomes a part of the database and it is always is executed
when the event for which it is defined occurs.
The SQL verbs that fire the Create, i.e. it may be INSERT,
UPDATE or DELETE.
table-name
Condition
ARCHIVE FILE:
These are files that can be created by a process known as archiving. When
a database operates in archive log mode, the contents of the redo log file
are transferred to an offline file known as the archive file. This file is very
useful in the event of a failure and is used for recovery purposes. Usually
complete recovery up to the point of failure is possible if all archive files
are available. Archive files can be created on disk and transferred to tape
to create space for new archive files.
Commit
Begin _Transaction
Abort
Begin _Transaction
System
Forces Abort
Durability: Once a transaction is committed, the system must guarantee
that the results of operations will never be lost, independent of
subsequent failures. The activity of providing Durability of the transaction
is called Database recovery.
A trigger is a data base object, like a table or an index. When you define a
trigger, it becomes a part of the database and it is always is executed
when the event for which it is defined occurs.
We could then use the CREATE TRIGGER statement to create an BEFORE DELETE trigger as
follows:
BEGIN
-- Find username of person performing the DELETE on the table
SELECT user INTO v_username
FROM dual;
-- Insert record into audit table
INSERT INTO orders_audit
( order_id,
quantity,
cost_per_item,
total_cost,
delete_date,
deleted_by )
VALUES
( :old.order_id,
:old.quantity,
:old.cost_per_item,
:old.total_cost,
sysdate,
v_username );
END;
Implicit cursors
Explicit cursors
Implicit cursors are declared by ORACLE for each UPDATE, DELETE and
INSERT SQL commands. Explicit cursors are declared and used by the user
to process multiple row, returned by SELECT statement. The set of rows
returned by a query is called the Active Set. Its size depends on the
number of rows that meet the search criteria of the SQL query. The data
that is stored in the cursor is called the Active Data Set.
ORACLE cursor is a mechanism used to easily process multiple rows of
data. Cursors contain a pointer that keeps track of current row being
accessed, which enables your program to process the rows at a time.
SOLUTION:
DECLARE
CURSOR a_emp
IS
SELECT *
FROM employees
WHERE emp_age > 45;
a_emp employees.a_emp%TYPE;
BEGIN
OPEN a_emp
LOOP
FETCH a_emp;
END LOOP;
CLOSE a_emp;
END;