Sei sulla pagina 1di 19

Oracle Apps Interview Questions

SQL/Scenarios
PLSQL/Scenarios
Oracle Apps /API/Migration
FORMS PERSONALISATION
XML PUBLISHER REPORT/RDF Report
OAF

Sl.No
1

2
3
4

6
7
8
9

10

11

12

13

14

15

16

17
18
19
20
21
22
23
24

Question
Basic
Which datatype stores data outside Oracle Database?

Can we rename a existing column in a table


What is a view? Can we update a view?
Can we delete a row in a view, if the view definition has 'DISTINCT' keyword.
Command to change the view definition without dropping the view
If you perform below query, how the ouput will be ordered??
SELECT empno,enumber, ename
FROM emp ORDER BY 1;

How to delete duplicate records in a table.


Can we use column alias in ORDER BY and WHERE clause
SELECT * FROM emp WHERE ename BETWEEN 'A' AND 'C'
Maxmium limit of 'IN' operator.
If you have more than 1000 values, how u will handle using 'IN' operator.

Write a query searches for PRODUCT_ID values that begin with DI_ from the ORDERS table?
Consider the following two SQL statements:
1. SELECT empno, ename, sal, comm
FROM emp WHERE comm IN (0, NULL);
2. SELECT empno, ename, sal, comm
FROM emp WHERE comm = 0 OR comm IS NULL;
Will it provide same result?

SINGLE_ROW Functions
SELECT last_name, first_name, start_date
FROM employees
WHERE hire_date < TRUNC(SYSDATE) - 5;

Use of INSTR

SUBSTR
FILE_PATH
C:\ORACLE\ORADATA\W11GR1\USERS01.DBF
C:\ORACLE\ORADATA\W11GR1\EXAMPLE01.DBF
Get me the file_name, using INSTR and SUBSTR.

DECODE function
CHAR VS VARCHAR2
Create table temp
(City CHAR(10),
Street VARCHAR(10));
Insert into temp
values('Pune','Oxford');
select length(city), length(street) from temp;
COALESCE
Difference between Primary key and unique key
How to get max salary from emp table.
How to get second max salary from emp table.
what is the difference between count(*) and count(column_name)
Difference between rownum and rowid
Difference between view and materialized view
How to refresh a materialized view

Ans
BFILE

Yes

empno

Self-Join
Rank
AnalyticFunction
ORDER BY- Yes
WHERE - No
3
1000

Using ESCAPE clause

No

Compare 1,2,3,Default with region_id

COALESCE(x1,x2,x3,x4)

DBMS_SNAPSHOT.REFRESH( 'v_materialized_foo_tbl','f');
second defines type of fresh f- fast refresh

Explanantion

The BFILE datatype stores only the locator to an external file in the database the actual data
RENAME TABLE tbl_name TO new_tbl_name
[, tbl_name2 TO new_tbl_name2]
OR
ALTER TABLE orig_name RENAME new_name;

A simple view can be updated. Rows cannot be deleted through a view if the view definition contains t
OR REPLACE

DELETE FROM
table_name A
WHERE
a.rowid >
ANY (
SELECT
B.rowid
FROM
table_name B
WHERE
A.col1 = B.col1
AND
A.col2 = B.col2
);

ALLEN,BLAKE,ADAMS, it will not retrive 'CLARK'

SELECT * FROM ORDERS


WHERE PRODUCT_ID LIKE DI\_%' ESCAPE \';
Can I write like this?
SELECT * FROM ORDERS
WHERE PRODUCT_ID LIKE DI#_%' ESCAPE #';

For NULL comparison you should be use with only IS NULL. The comm IN (0, NULL) will be treated as c

Employees hired more than five days ago

INSTR(c1, c2[,i[,j]]) takes four arguments, where c1 and c2 are character strings and i and j are intege
function returns the numeric character position in c1 where the j occurrence of c2 is found. The search
character position in c1. INSTR returns a 0 when the requested string is not found. If i is negative, the
performed backward, from right to left, but the position is still counted from left to right. Both i and j d
cannot be negative.
Eg: SELECT INSTR('mississippi','i',4,1) from dual; - Ans: 5
Here is another example using a negative argument for the beginning character position. The search f
start at the fourth position from the end and move to the left.
SELECT INSTR('mississippi','is',4,1) from dual; Ans: 5

SUBSTR(c1, x [, y]) takes three arguments, where c1 is a character string and both x and y are integer
function returns the portion of c1 that is y characters long, beginning at position x. If x is negative, the
backward (that is, right to left). This function returns NULL if y is 0 or negative. y defaults to the remai

SELECT SUBSTR(file_path, INSTR(file_name,'\', -1,1)+1) name FROM dba_data_files;


SELECT country_id, country_name, region_id,
DECODE(region_id, 1, 'Europe',
2, 'Americas',
3, 'Asia',
'Other') Region
FROM countries

CHAR is used for Fixed Length Size Variable


VARCHAR is used for Variable Length Size Variable.
Return first not null values in x1,x2,x3,x4, If all are null value it will retrive 'NULL'
Primary Key cannot be NULL But unique key can have NULL values

count(*) will give including NULL values, count(column_name) exclude NULL value

Sl.No

Question
1 Can you please write a plsql structure

What are % TYPE and % ROWTYPE


In the declarative section of a PL/SQL block, you created but did not initialize a
number variable.
2 When the block executes, what will be the initial value of the variable?
2 What is an exception?
3 What are the different kind of exception?
4 What is the difference between procedure and function
Different modes of parametes in procedure.
Which paramet is passed by value and by reference.
IN OUT??
5 Use of NO COPY in parameter
6 How to raise an user defined exception
7 Use RAISE_APPLICATION_ERROR

8 What is Exception_INIT pragma


9 What are the return values of functions SQLCODE and SQLERRM ?

What is a cursor and different type of cursor.


10 And Their difference.

11 Cursor Attributes

12 What is FOR UPDATE cursor


13 Can we open mutliple cursor at the same time.

13 What is a TRIGGER. Different types of trigger

14 Syntax for trigger


15 What is INSTEAD OF trigger?

16 Maxmimum number of triggers that can be applied to a tabkle


Can we write commit on a trigger. Give me an example in your project.
17 How to debug a program. What is AUTONOMUS_TRANSACTION.
18 What is mutating trigger
19 How to invoke a procedure from an another procedure
20 How to release a lock in a table.

21 What is a collection.? Differenet types?

22 Two types of PLSQL Tables23 NATIVE DYNAMIC SQL

24 What is a global temporary table?


25

I want to declare a variable in a package, which needs to be used across


differenet procedures under the package.

26 What is a PLSQL Record

27 PL/SQL can handle the following types of records:

DECLARE
BEGIN
update emp set sal = sal*2
where deptno = 100;
EXECPTION
WHEN NO DATA FOUND
WHEN OTHER
END;
IF deptno 100 is not available in emp table. Which exception it will raise
28
29 BULK COLLECT AND DYNAMIC SQL

Ans

NULL
USER_DEFINED and PRE-DEFINED

IN- Passed by reference.


OUT- Passed by value.
In declare section u have to declare the exception
No need to declare and put it in exception.

DECLARE
v_zip zipcode.zip%type := '&sv_zip';
e_child_exists EXCEPTION;
PRAGMA EXCEPTION_INIT(e_child_exists, -2292);
BEGIN
DELETE FROM zipcode
WHERE zip = v_zip;
DBMS_OUTPUT.PUT_LINE ('Zip '||v_zip||' has been deleted');
COMMIT;
EXCEPTION
WHEN e_child_exists THEN
DBMS_OUTPUT.PUT_LINE ('Delete students for this '||
'zipcode first');
END;

Implicit and Expilict

The purpose of using the FOR UPDATE clause is to lock the rows of the
tables you want to
update so that another user cannot perform an update until you
perform your update and
release the lock.
Yes

12

A trigger giving select on the table which the trigger is written


procedure_name(parameter);
sid from v$lock, serial# from v$session.
Alter system kill session sid, serial#

A Collection is a group of elements of the same datatype. Each element


is identified by a unique subscript that represents its position in the
collection.
PLSQL Tables- More similar to a one-column database column.
Two type Associative tables and nested tables.

These tables do not reside in the system catalogs and are not
persistent. Temporary tables exist only during the connection that
declared them and cannot be referenced outside of that connection.
When the connection closes, the rows of the table are deleted, and the
in-memory description of the temporary table is dropped.

A PL/SQL record is a data structure that can hold data items of different
kinds. Records consist of different fields, similar to a row of a database
table.

Table Based
Cursor Based
User Defined

It wont raise any exception as it is a update statement.

Explanantion
% TYPE provides the data type of a variable or a database column to that
variable.
% ROWTYPE provides the record type that represents a entire row of a table or
view or columns selected
in the cursor.

TOO_MANY_ROWS,NO_DAT_FOUND,ZERO_DIVIDE,INVALID_CURSOR

Pass By Reference : Using the NOCOPY hint tells the compiler to use pass by reference,
RAISE_APPLICATION_ERROR (-20000, 'An id cannot be negative');

The EXCEPTION_INIT pragma allows you to associate an Oracle


error number with the name of a user-defined error.
SQLCODE returns the latest code of the error that has occured.
SQLERRM returns the relevant error message of the SQLCODE.
1Explicit cursor will be defined in the declaration section but implicit cursor
will be defined in the execution or body section.
2The implicit cursor must have INTO clause in its SQL statement.
3The explicit cursor can return more than one record but the implicit cursor
should only return one and only one record.

%ISOPEN - to check whether cursor is open or not


% ROWCOUNT - number of rows featched/updated/deleted.
% FOUND - to check whether cursor has fetched any row. True if rows are
featched.
% NOT FOUND - to check whether cursor has featched any row. True if no rows
are featched.

CURSOR c_course IS
SELECT course_no, cost
FROM course FOR UPDATE;
Application Trigger and Database Trigger.
Based on Level:
Statement Level and Row Level.
Based on Timings:
Before,After,Instead of.

CREATE [OR REPLACE] TRIGGER Ttrigger_name


{BEFORE|AFTER} Triggering_event ON table_name
[FOR EACH ROW]
[FOLLOWS another_trigger]
[ENABLE/DISABLE]
[WHEN condition]
DECLARE
declaration statements
BEGIN
executable statements
EXCEPTION
exception-handling statements
END;
3- in/upd/del
2- beofer/after
2- rowlevel/statement/level

Records:
Table Based, Cursor Based, Program Defined.
PLSQL Tables:
Varrays:
Nested Tables:
TYPE type_name IS TABLE OF element_type [NOT NULL]
INDEX BY element_type;
table_name TYPE_NAME;

Eg: of user defined


DECLARE
TYPE books IS RECORD
(title varchar(50),
author varchar(50),
subject varchar(100),
book_id number);
book1 books;

EMPNO
ENAME


7369 SMITH
7499 ALLEN
7521 WARD
7566 JONES
7654 MARTIN
7698 BLAKE
7782 CLARK
7788 SCOTT
7839 KING
7844 TURNER
7876 ADAMS
7900 JAMES
7902 FORD
7934 MILLER

SALARY
COMM
DEPTNO



800
20
1600
300
30
1250
500
30
2975
20
1250
30
2850
30
2450
24500
10
3000
20
5000
50000
10
1500
0
30
1100
20
950
30
3000
20
1300
13000
10

Potrebbero piacerti anche