Beruflich Dokumente
Kultur Dokumente
8 View
View is presentation of one or more table or it is a virtual table
View is database object is used to register the sql statement permanently in the
database
It is used to reduce the object size
It is to hide the complex data
It used for security purpose also
9 Correlated subquery
are used for row-by-row prcessing.Each
subquery is executed once for every row of the outer
query.It is one way of reading every row in a table and
camparing the values in each row againt the realted data.
SELECT first_name, salary, department_id
FROM employees OUTER
WHERE salary > (SELECT AVG (salary)
FROM employees
WHERE department_id = OUTER.department_id);
Each time a row from the outer query is processed,the inner
query is evaluated.
10 What is rowid?
It gives the location in the database where row is
physically stored.
ROWID is a pseudo column attached to each row of a table. It is 18 characters
long, blockno, rownumber are the
components of ROWID.
11 integrity constraint
which prevents the user from entering the duplicating into
tables or views is called integrity constraint
Ex: primary key constraint,foreign key constraint,unique
constraint,check constraint.
12 Referential integrity,
Referential integrity, also known as relational integrity, means that if a table
contains a foreign key column, then
every value in that column (except NULL, if it is allowed) will be found in the
primary key of the table that it is
related to, or reference
16 How many LONG columns are allowed in a table? Is it possible to use LONG
columns in WHERE clause or
ORDER BY?
Only one LONG column is allowed. It is not possible to use LONG column in WHERE
or
ORDER BY clause.
17 What are the pre-requisites to modify datatype of a column and to add a colum
n
with NOT NULL
constraint?
- To modify the datatype of a column the column must be empty.
- To add a column with NOT NULL constrain, the table must be empty.
22 AUTONOMOUS_TRANSACTION
An autonomous transaction is an independent transaction that is initiated by
another transaction, and executes without interfering with the parent transactio
n.
When an autonomous transaction is called, the originating transaction gets
suspended. Control is returned when the autonomous transaction does a COMMIT or
ROLLBACK
A trigger or procedure can be marked as autonomous by declaring it as PRAGMA
AUTONOMOUS_TRANSACTION
PROCEDURE test_autonomous
IS
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
insert ....
commit;
END test_autonomous;
25 PL/SQL RECORD
A record is a group of related data items stored in fields, each with its
own name and datatype. A record containing a field for each item lets you treat
the data as a logical unit. Thus, records make it easier to organize and represe
nt
information.
DECLARE
TYPE r1 IS RECORD (
employee_id NUMBER (5),
first_name VARCHAR2 (10),
hire_date DATE
);
r2 r1;
BEGIN
SELECT employee_id,
first_name,
hire_date
INTO r2
FROM employees
WHERE employee_id = 101;
DBMS_OUTPUT.put_line (r2.employee_id || ' ' || r2.first_name || ' ' ||
r2.hire_date);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
raise_application_error (-20023, 'INVALID EMPLOYEE NUMBER');
END;
101 Neena 21-SEP-89
Statement processed.
31 What is the difference between When no data Found and cursor attribute % DATA
FOUND?
When no Data Found is a predefined internal exception in PLSQL.
Where as % Data found is a cursor attribute that returns YES when zero rows are
retrieved and returns NO when at least one row is retrieved.
34 What should be the return type for a cursor variable. Can we use a scalar dat
a
type as return type?
The return type of a cursor variable can be %ROWTYPE or record_name%TYPE or a
record type or a ref cursor type. A scalar data type like number or varchar cant
be used but a record type may evaluate to a scalar value.
37 Without closing the cursor, If you want to open it what will happen. If error
,
get what is the error?
If you reopen a cursor without closing it first,PL/SQL raises the predefined
exception CURSOR_ALREADY_OPEN.
39 What are Exceptions? How many types of Exceptions are there?
Exceptions are conditions that cause the termination of a block. There are two
types of exceptions
Pre-Defined Predefined by PL/SQL and are associated with specific error
codes.
User-Defined Declared by the users and are rose on deliberate request.
(Breaking a condition etc.)
Exception handlers are used to handle the exceptions that are raised. They
prevent exceptions from propagating out of the block and define actions to be
performed when exception is raised.
48 You have just compiled a PL/SQL package but got errors, how would you view th
e
errors?
SHOW ERRORS
52 Can cursor variables be stored in PL/SQL tables. If yes how. If not why?
Yes. Create a cursor type - REF CURSOR and declare a cursor variable of that typ
e.
DECLARE
/* Create the cursor type. */
TYPE company_curtype IS REF CURSOR
RETURN company%ROWTYPE;
/* Declare a cursor variable of that type. */
company_curvar company_curtype;
/* Declare a record with same structure as cursor variable. */
company_rec company%ROWTYPE;
BEGIN
/* Open the cursor variable, associating with it a SQL statement. */
OPEN company_curvar FOR
SELECT *
FROM company;
/* Fetch from the cursor variable. */
FETCH company_curvar
INTO company_rec;
/* Close the cursor object associated with variable. */
CLOSE company_curvar;
END;
54 When you use WHERE clause and when you use HAVING clause
HAVING clause is used when you want to specify a condition for a group function
and it
is written after GROUP BY clause
The WHERE clause is used when you want to specify a condition for columns, singl
e
row functions except group functions and it is written before GROUP BY clause if
it is
used.
58 What is a schema ?
A schema is a logical collection of database objects like tables, views, pkgs,
procedures, triggers, etc. It usually has an associated database user.
59 What is a mutating table error and how can you get around it?
This happens with triggers. It occurs because the trigger is trying to update a
row it is currently using. The usual fix involves either use of views or tempora
ry
tables so the database is selecting from one while updating the other.
61 What is SQLCODE?
A predefined symbol that contains the Oracle error status of the previously
executed PL/SQL statement. If a
SQL statement executes without errors, SQLCODE is equal to 0.
62 What is SQLERRM?
A PL/SQL symbol that contains the error message associated with SQLCODE. If a SQ
L
statement executes
successfully, SQLCODE is equal to 0 and SQLERRM contains the string ORA-0000:
normal, successful completion
64 What is a Synonym ?
A synonym is an alias for a table, view, sequence or program unit.
69 What is a SNAPSHOT ?
Snapshots are read-only copies of a master table located on a remote node which
is
periodically refreshed to reflect changes made to the master table.
73 Srw package
FND SRWINIT: This User Exit is used to initialize the report in the memory.
FND SRWEXIT: This User Exit is used to release the memory occupied by the
program.
FND FLEXSQL: This User Exit is used to tailor the SELECT statement which returns
Call FND SRWINIT User Exit in Before Report Trigger.
BEGIN
SRW.USER_EXIT ( FND SRWINIT );
RETURN (TRUE);
END;
Call FND SRWEXIT User Exit in After Report trigger.
BEGIN
SRW.USER_EXIT ( FND SRWEXIT );
RETURN (TRUE);
END;
Call FND FLEXSQL User Exit in Before Report Trigger.
BEGIN
SRW.USER_EXIT ( FND SRWEXIT );
BEGIN
SRW.REFERENCE ( :P_STRUCT_NUM );
SRW.USER_EXIT ( FND FLEXSQL
APPL_SHORT_NAME = "SQLGL"
CODE = "GL#"
NUM = ":P_STRUCT_NUM"
OUTPUT = ":P_FLEXDATA"
MODE = "SELECT"
DISPLAY = "ALL" );
END;
RETURN (TRUE);
END;
76 How can u call a standard interface program from sql or pl/sql code?
FND_REQUEST.SUBMIT_REQUEST ( PO , EXECUTABLE NAME ,,,,PARAMETERS)
88 What is a flexfield?
A flexfield is a flexible field which is used to capture mandatory or non
mandatory business information.
92 What is the max no of segments that can be defined for the accounting flexfie
ld
structure?
30
96 What are the flexfield qualifiers which are available for accounting flexfiel
d
structure?
Natural account, Cost center, Balancing, Intercompany
98 ALERTS
Oracle Alert will send messages or perform predefined
actions in an action set when important events occur
There are two types of Alerts
1. An event alert
2. A periodic alert
An event alerts: Event alerts immediately notifies the activity (i.e. an insert
or an
update to a table) in the database as it happens/ occurs.
A periodic alerts: Periodic alerts periodically report key information according
to
as
chedule you define.
105 How to find out the database name from SQL*PLUS command prompt?
Select * from global_name;
This will give the datbase name which u r currently connected to.....
106 What is diffrence between Co-related sub query and nested sub query?
Correlated subquery runs once for each row selected by the outer query. It conta
ins a
reference to a value from the row selected by the outer query.
Nested subquery runs only once for the entire nesting (outer) query. It does not
contain any
reference to the outer query row.
For example,
Correlated Subquery:
select e1.empname, e1.basicsal, e1.deptno from emp e1 where e1.basicsal = (selec
t
max(basicsal) from emp e2 where e2.deptno = e1.deptno)
Nested Subquery:
select empname, basicsal, deptno from emp where (deptno, basicsal) in (select de
ptno,
max(basicsal) from emp group by deptno)