Vous êtes sur la page 1sur 14

BT 10-01

Oracle/Developer 2000

1: - EXPLAIN ROLLBACK, COMMIT & SAVEPOINT WITH EXAMPLE.


ANS: -
ROLLBACK: -
This statement is used to release a single transaction or all
transaction. This statement must be used before commit statement.

COMMIT: -
In oracle, whatever transactions we perform with a table are
Temporary in nature. To make them permanent commit must
be issued.

SAVEPOINT: -
The savepoint statement is used to give a name to a
Transaction and then the rollback statement uses these name
To release a transaction.

2 WHAT IS LOCK TABLE? EXPLAIN DIFFERENT TYPES OF LOCK


TABLE.

ANS:

LOCK TABLE: -
Locks are metarism used to prevent the interactive destruction
between the users using same resource. Locks determine what will happen when
the two users attempt to modify the same row at the same time.

There are two types of locks supported by Oracle engine.

• Shared locks -

=> Shared locks are placed on resources whenever a Read operation (SELECT)
is performed.
=> Multiple shared locks can be simultaneously set on a resource.
• Exclusive locks: -

=> Exclusive locks are placed on resources whenever write operations


(INSERT, UPDATE & DELETE) are performed.
=> Only one lock can be placed on a resource at a time i.e. the first user who
acquires an exclusive lock will continue to have the sole ownership of the
resource and lock on that resource.

3: - WHAT ARE DATA CONSTRAINTS IN ORACLE? NAME DIFFERENT


TYPES OF
DATA CONSTRAINTS WITH EXMPLES.
ANS: -
Data constraints: -
Rules which are enforced on data being entered, and prevent the user
from entering invalid data into tables are called constraints. Thus, constraints
super control data being entered in tables for permanent storage.

Types of data constraints: -


There are two types of data constraints that can be applied to data
being inserted into an Oracle table. One type of constraints is called an I/O
constraint (input/output). This data constraint determines the speed at which data
can be inserted or extracted from an Oracle table. The other type of constraint is
called a Business Rule constraint.

4: - EXPLAIN DIFFERENT DATA TYPES IN ORACLE.


ANS: -
The different data types in oracle are: -
Char:-
This data type is used to store character string values of fixed
length. This data type can hold maximum of 255 characters.

Varchar/Varchar2:-
This data type is used to store alphanumeric data. The
maximum length of this data type is 2000 characters.

Number:-
It is used to store numbers either fixed or floating.
Date:-
This data type is used to represent date and time.

Long:- Cells defined as long can store variable length character strings
containing up to 65,535 characters.

5: - EXPLAIN DIFFERENT TYPES OF JOIN OPERATORS WITH


EXAMPLE.
ANS: -
Introduction: -
Joins means to access rows from the table. Join operator is
essential to retrieve data from two tables. Join operation contains two
table with a where clause in which common key fields must be specified.

Different type of joins: -

 Equi Joins: -
When matching records are only displayed from both the tables.
Tables are joined columns, which have same data type and rows. When
two or more tables are joins on the basis of equality of values in one or
more table they make equi join.
E.g.: - Let’s create two tables Player and Match. In both the tables one field is
same i.e. Roll no. When we retrieve data from the tables we have to join the
roll no of both the tables. Match is considered as foreign key and roll no,
player is considered as primary key.
Select player.rollno, name, match date opponent
From player, match
Where player.rollno=match.rollno;

 Outer joins:-
If there is any value in one table which have the corresponding
value(s) in
other table then Equi join rows are not selected. The rows can be selected by
using outer join symbol (+). The corresponding for the column is null. The data
that is not presented in the second file will be presented as null values.
E.g.: - Select player.rollno, name, match date opponent
From player, match
Where player.rollno=match.rollno;

Rules to place (+) operator: -


=> The outer join symbol cannot be on both sides.

=> It is not possible to join the same table to one or more tables with single
select statement.

=> The outer join may not be used with one or more operator.

6: - EXPLAIN DIFFERENT TYPES OF LOOPING IN ORACLE.


ANS: -
LOOP COMMAND:-

The loop command initializes a group of command indefinitely, or


until a condition forces a “break” in the loop and detours the execution of the
program to another place. This is done with the help of exit command, which is
responsible for interrupting the loop execution.

SYNTAX:-
LOOP
<COMMAND>
EXIT
<COMMAND>
END LOOP;

Whenever the commands are executed inside a loop the cycle restarts in
the command following that loop when exit is executed, the execution control
passes to the row following the end loop command.

FOR LOOP COMMAND:-

The “for” loop command is the variation of the loop command.


Here the
Command is automatically executed until evaluated condition returns false.

SYNTAX:-
FOR <COUNTER>IN [REVERSE] <INITIAL-VALUES>
<FINAL-VALUES> LOOP
<COMMANDS>
END LOOP;

THE WHILE COMMAND:-


The “while” command is another a control structure. This
structure only
executes the command if the analyzed condition is true .

SYNTAX:-

WHILE<CONDITION>
LOOP
<COMMAND>

7: - WHAT IS SUBQUERY? EXPLAIN ITS USE.

ANS: -
A sub query is a form of an SQL statement that appears inside
another SQL statement. It is also treated as nested query. The statement containing
a sub query is called parent statement.
Uses: -

(1) To insert record in a target table.


(2) To create table and insert record in the created table.
(3) To update records.
(4) To provide condition in WHERE, HAVING etc used with SELECT, UPDATE
and DELETE statements.

8: - EXPLAIN FUNCTION, PROCEDURES AND PACKAGES.

ANS: -
There are three types of Procedural objects. They are as follow:-

 Procedures: -
 Functions: -
 Packages: -

PROCEDURES:
Procedures are sub programs, which receives parameters and
performs a specified action. In order to create procedures we use <create
procedure> statement. It has the following form: -

CREATE [OR REPLACE] PROCEDURE <PROCEDURE NAME>


(ARGUMENT [IN/OUT/INOUT] DATATYPE) [IS/AS]
<VARIABLE DECLARATION>
BEGIN
<PROCEDURE BODY>
END [RPOCEDURE NAME];

TO PASS PARAMETER FOR EXECUTION: -

SQL>EXECUTE<procedure name> (parameter);

DROPPING A PROCEDURE: -
DROP PROCEDURE <PROCEDURE NAME>;

Procedures may be executed from a trigger also. To execute the procedures


named, VALIDATE by passing a parameter, i.e. the new basic value,

VALIDATE (:NEW.BASIC);

PRAMETERS TO PROCEDURES:-
Communication is passed In or Out through procedures with the
help of a parameter. The parameters passed also known as actual
parameters which can be positional or named notation.

FUNCTIONS:

Functions are also a collection of SQL and PL/SQL code which


receives the parameter performs the action and returns a value to the
caller. Procedure and Functions are same except that a Function has
always a return value. This value is returned through the use of the
RETURN keyword within the function. RETURN<VARIABLE
NAME>A function can return single value to the caller.

SYNTAX OF FUNCTION: -
CREATE [OR REPALACE] FUNCATION <FUNCTION NAME>
(ARGUMENT (IN/OUT/INOUT) DATATYPE) RETURN <RETURN
TYPE>
[IS/AS] <DECLARATION>
BEGIN
<FUNCTION BODY>
END [FUNCTION NAME];

PACKAGES:-

Packages are group of Procedures, Functions, Cursors, Variables


and SQL
Statement in single unit. A Package usually has two parts: -
(a) Package Specified &
(b) Package Body. They need to be created separately.

(A) A Package Specification is an interface which declares


Procedures, Cursors, Functions and Variables available for use.
SYNTAX: -
CREATE [OR REPLACE] PACKAGE <PACKAGE NAME>
[IS/AS]
VARIABLES DECLARARION
CURSORS DECLARATION
PROCEDURES DECLARATION
FUNCTIONS DECLARATION
EXCEPTIONS DECLARATION
END [PACKAGE NAME];

(B) A Package Body fully contains PL/SQL block for all the
objects listed in the Package specified. The name of the
Package Body should be the same as the name of the
Package Specification.
SYNTAX: -
CREATE [OR REPLACE] PACKAGE BODY <PACKAGE
NAME> [IS/AS] PL/SQL CODE BLOCK FOR ALL THE
LISTED OBJECTS
END [PACKAGE NAME];

To execute a procedures within a packages, first list the packages


name, then the procedures name, as shown in the example,

EXECUTE SALARY_PACKAGE.NEW_WORKER (‘MAHE’)


In the preceding example, the NEW_WORKER procedure within the
SALARY_PACKAGE is executed.
Packages allow multiple procedures to use the same variables and cursors.
Procedures within packages may be available to the public or they may be
private, in which case they are only accessible via commands from within the
packages.

9: - WHAT IS CURSOR? EXPLAIN TWO TYPES OF CURSOR.


ANS: -
Cursors are used when the SQL select statement is expected to return
more than one row. Example, a query like, SELECT* FROM CSTMAST
WHERE CITY=’UDP’ or a query like SELECT *FROM SALARY WHERE
BASIC>3000. So, cursor is a buffer which will store the result of the recent
query.
A cursor should be declared and its definition should contain the query.
It must be defined in the DECLARE section of the program and must be
opened before processing and close after processing.

SYNTAX TO DECLARE THE CURSOR: -

CURSOR <CURSOR NAME> IS <SELECT STATEMENT>;

SYNTAX TO OPEN THE CURSOR: -

OPEN <CURSOR NAME>;

SYNTAX TO STORE DATA IN THE CURSOR: -

FETCH <CURSOR NAME> INTO<RECORD NAME/LIST OF


VARIABLE>;

SYNTAX TO CLOSE THE CURSOR:

CLOSE <CURSOR NAME>;

TYPES OF CURSORS:-
Cursors are classified in two categories: -
(a) Explicit Cursor &
(b) Implicit Cursor. These cursors are user defined cursors which can be used to
process DML statement such as Insert, Update, Delete or Select in multiple
rows at a time.

 EXPLICIT CURSORS:-
When individual records in the table have to be processed inside a
PL/SQL
Block a cursor is used. This cursor will be declared and mapped to an SQL
query in the declarative section of the PL/SQL block and used within the
executable section. A cursor thus created and used is known as an EXPLICIT
CURSOR.

 IMPLICIT CURSORS:-
The Implicit cursor is used to process single record in a table.
Implicit cursor is not needed to be declared by the user. It is
automatically declared by the cursor when PL/SQL block is executed.
Implicit cursor attributes can be used to access information about
the
status of last insert, update, delete or single-row select statement.

10: - WHAT IS PL/SQL TRIGGER AND WHEN IT IS EXECUTED?


ANS: -
A trigger consists of PL/SQL code, which performs an action in a table
whenever an event such as Insert, Update or Delete takes place. It executes
automatically and performs an action for which the Trigger has been written.
The execution of the Trigger is also transparent for the user.
SYNTAX: -
CREATE [OR REPLACE] TRIGGER <TRIGGER NAME>
[AFTER/BEFORE] [INSERT/UPDATE/DELETE]
ON <TABLE NAME> [FOR EACH ROW]
[WHEN] <TRIGGER CONDITION>
BEGIN
<TRIGGER BODY>
END;

EXECUTION OF A TRIGGER:-

Once a trigger is created, it is associated with the table on which it


is
created. This trigger will be executed when the user executes an UPDATE
statement on the table.
Create the table, SALARYAUD into which data must be inserted when
the trigger is fired. For example, a trigger named, UPDSAL has been created
and it is associated with the table, SALARY. This will be executed when the
user types the following: -

SQL> UPDATE SALARY SET BASIC=3500 WHERE EMP_NO=1001;


Data will be updated in the SALARY and the old data will be added to
the table, SALARYAUD. This can be viewed by executing the select
statement.

DROPPING A TRIGGER: -
SYNTAX: -
DROP TRIGGER <TRIGGER NAME>;

DISABLING A TRIGGER: -
SYNTAX: -
ALTER TRIGGER <TRIGGER NAME> DISABLE;

ENABLING A TRIGGER: -
SYNTAX: -
ALTER TRIGGER <TRIGGER NAME> ENABLE;

TO DISABLE ALL TRIGGERS: -


SYNTAX: -
ALTER TRIGGER <TRIGGER NAME> DISABLR ALL
TRIGGERS;

TO ENABLE ALL TRIGGERS: -


SYNTAX: -
ALTER TRIGGER <TRIGGER NAME> ENABLE ALL
TRIGGERS;

BT 10-02
ORACLE/DEVELOPER

1: - WHAT IS PL/SQL TABLE? EXPLAIN ITS FEATURES.


ANS: -
The PL/SQL table is similar to the Array of ‘C’ or ‘C++’ language. It is also
known as object type of table, which is modeled on database tables. It uses a
primary key to give us array, like access to rows. The size of PL/SQL table is
unconstrained i.e. is the number of rows in PL/SQL table can increase
dynamically.

Syntax:-
TYPE <NAME>IS TABLE OF <DATA TYPE>
INDEX BY BINARY_INTEGER;
NOTE: - After declaring PL/SQL table we must declare a variable of this table in
the declarative section of PL/SQL block by using the following syntax: -

<NEW NAME> <OLD NAME>;

2: - WRITE A PL/SQL BLOCK TO DISPLAY THE REVERSE OF NUMBER


BETWEEN ONE AND HUNDRED.
ANS: -
BEGIN
FOR A IN REVERSE 1…..100 LOOP
DBMS_OUTPUT.PUT_LINE (‘Loop number :’|| A);
END LOOP;
END;
After the Procedure is completed successfully, you have to use the
keyword: -
SET SERVEROUTPUT ON; To view the result.

3: - WHAT THE DIFFERENCE BETWEEN DELETE AND TRUNCATE


COMMANDS?
ANS: -
DELETE Command:-
It is used to delete entire or specified row from a table. It
deletes the complete row that is specified in the given condition so that no cell
name will be issued or accepted.

Syntax: -
Delete from < table name>
[ where condition ];

Ex. Delete the detail of those employees who is designated as a clerk.

Delete from employee


where desg =’clerk’;

TRUNCATE Command:-
It returns the number up to given decimal place.
Select trunk (26.648, 1) from dual =26.6

4: - WRITE THE SYNTAX TO CREATE TABLE.


ANS: -
Create table Employee
(Empno varchar2 (6) primary key,
Empname varchar2 (15) not null,
Empsal number (8,2) not null,
Deptno number (3) not null,
Hire date date);

5: - WRITE QUERIES.
ANS: -
a) Select sum (empsal)”salary”
from employee;

b) Select min (empsal)”salary”


from employee;

c) Select * from employee


Where salary>5000 and salary<8000;

d) Alter table employee


modify (empname varchar2 (25));

6: - EXPLAIN DDL, DML & DCL WITH EXAMPLE.


ANS: -
DDL:
Data Definition Language .The SQL Sentences that are used to create
objects are called DDL. Ex: - CREATE, ALTER, DROP.

DML: -
Data Manipulation Language . The SQL Sentences used to
Manipulate data within objects are called DML. Ex: - TNSERT, UPDATE,
SELECT, DELETE.

DCL: -
Data Control Language . The SQL Sentences which are used to
Control the behaviors of these objects are called DCL. Ex: - CREATE USER,
GRANT, and REVOKE.
7: - WHAT IS AN LOV? EXPLAIN ITS USE.

ANS: -
During data entry often a user has to enter that already exists in same or other
table. LOV stands for list of values it is used to retrieve data already existing in a
table using a select, opens up a separate window displaying value from one or
more table when the user presses an appropriate key sequence.

8: - WHAT IS AN ALERT? EXPLAIN ITS USES.


ANS: -
An Alert is a modal that displays a message notifying the user of some application
condition. Modal windows are windows, which cannot be dismissed without
clicking on any of the options displayed. Modal windows cannot be sized.
Oracle Forms has many built-in alerts that display pre-
defined messages. We can also create our own custom alerts that display in
response to application- specific events. We use alerts to advise users of
unusual situations or to warn users who are about to perform an action that
might have undesirable or unexpected consequences.
There are three styles of alerts: Stop, Caution, and Note.
Each style denotes a different level of message severity. A unique icon that
displays in the alert window, when an event occurs that causes an alert to
display represents message severity visually, the operator must respond to the
alert’s message by selecting one of the predefined alert buttons. Selecting any
button immediately dismisses the alert.

9: - WHAT IS THE DIFFERENCE BETWEEN CHECK BOXES AND RADIO


GROUPS?
ANS: -
Check Boxes: -
A check box is a text label with an indicator that displays
the current value as either checked or unchecked. Selecting a check box
toggles it to the opposite state.

Radio Group:
A radio group is a group of two or more radio buttons, one
of which is always selected. Operator changes the value of a radio group item
by selecting different button in the group.
10: - EXPLAIN ANY FOUR TYPES OF ORACLE REPORTS?
ANS: -
INTRODUCTION:
Reports are useful feature compatible with ORACLE. Its main
function is to generate reports based on the query specified. Hence, the first step to
develop the report is to specify the query and the required data.
Following are the four types of Oracle Reports:

(a) Tabular reports-


A tabular report is the most basic types of report. Each
column
correspond to a column selected from the database.

(b) Form-like reports-


A form-like report displays one record per page, inserting
field values to the right of field labels.

© Mailing label repots-


A mailing label report prints mailing labels in multiple
columns on each page. We can print the labels across
the page and then down, or down and then across.

(d) Form letter reports-


A form letter report contains database values embedded in
Boilerplate text.

Vous aimerez peut-être aussi