Sunday, November 29, 2009

Pl/Sql FAQ-1

1. What is the difference b/w subquery and correlated subquery?
a) In a normal subquery, the inner query is executed first and then the result are passed off to the parent query.
b) In a correlated subquery, the outer query is executed first and process each row, the subquery is using. The info supplies by the result of the outer query.

2. How to delete duplicate rows from a table?
Delete test t1 where rowed< (Select max(rowed) from test t2 where t2.col1 = t1.col and t2.col2 = t1.col1.

3. what are the types of database triggers?
Ro. Total no of database triggers are 12. They are
a) Row level : once for every row affected by the triggering statement such as a trigger fired by an update statement that updates many rows.
b) Statement level : once for the triggering statement, no matters be many rows it affects.
c) Before : before triggering statement is executed.
d) After: After triggering statement is executed.
e) Instead of : triggers provider a transparent way of modifying that cant be modified through DML statement.

4. what is mutating error on a table?
It happens when a trigger on a table tries to insert, update or ever select the table of where trigger is being executed.

5. What is synonym? What is view?
A synonym is an alias for any table, sequence, procedure function or package. It requires no storage other than its definitions in the data dictionary.
A view is stored query, from one or more tables.

6. What is database link?
A database link is a pointer that defines a one_way communication path from an oracle database server to another database server

7. What is a dynamic SQL?
DDL statement can’t be used within PL/SQL using “Execute Immediate”

8. What are set operator?
Set operators combine the result of two component queries into a single result queries containing set operator are called components queries
UNION : all rows selected by either query
UNION ALL : All rows selected by either query, including all duplicate
INTERSECT : All distinct rows selected by both queries
MINUS : All distinct rows selected by the first query but not the second.

9, What is savepoint?
Savepoint are intermediate markers within the context of a transaction savepoint divide a long transaction into smaller parts we then have to option later of rolling back work performed before the current point in the transaction but after a declared savepoint within the transaction.

10. What are the benefits of using package? Name few oracle supplied package
An entire package is loaded into memory when a procedure within the package is called for the first time. This load is completed in one operation, as opposed to the separate loads required for stand alone procedure. A package body can be replaced and recompiled without affecting the specification. Definition of procedure/variable can be private or public. For example I have 5 procedure out of 3 procedures can be used by a DBMS_SQL, DBMS_JOB, UTL_FILE.

11. What is deadlock?
A deadlock can occur when two or more user are waiting for data locked by each other. Deadlocks prevent some transactions from continuing to work.

2 comments:

  1. Excellent blog. You have shared plenty of useful articles that shares information about PL/SQL. I am too learning this interesting programming language and it will be a great support to me to take help on all the related topics. Thank you.
    sap ecc 6

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete