TOP
20 PL SQL INTERVIEW QUESTION
This
is probably the most asked question in plsql interview. It breaks the
ice and gets you to talk about something you should be fairly
comfortable with. Have something prepared that doesn't sound
rehearsed. It's not about you telling your life story and quite
frankly, the interviewer just isn't interested. Unless asked to do
so, stick to your education, career and current situation. Work
through it chronologically from the furthest back to the present.
A
PL/SQL table is one dimensional, indexed, unbounded sparsed
collection of homogeneous Data. PLSQL tables are used to move data
into and out of the database and between client side applications and
stored sub-programs. They have attributes such as exits, prior,
first, last, delete ,next . These attributes make PLSQL tables easier
to use and applications easier to maintain. Advantages: 1 PLSQL
tables give you the ability to hold multiple values in a structure in
memory so that a PLSQL block does not have to go to the database
every time it needs to retrieve one of these values - it can retrieve
it directly from the PLSQL table in memory. 2 Global temporary tables
act as performance enhancers when compared to standard tables as they
greatly reduce the disk IO. 3 They also offer the ease-of-use of
standard tables, since standard SQL can be used with them; no special
array-processing syntax is required.
This
will take an assessment of your experiences, skills and traits.
Summarize concisely: "I have a unique combination of strong
technical skills, and the ability to build strong customer
relationships. This allows me to use my knowledge and break down
information to be more user-friendly."
Cursor
is an identifier/name to a work area that we can interact with to
access its information. A cursor points to the current row in the
result set fetched. There are three types of cursors. They are 1
Implicit cursors – created automatically by PL/SQL for all SQL Dml
statements such as Insert Update, delete and Select 2 Explicit
cursors – Created explicitly. They create a storage area where the
set of rows Returned by a query are placed. 3 Dynamic Cursors – Ref
Cursors( used for the runtime modification of the select querry).
Declaring the cursor, Opening the cursor, Fetching data , Closing the
cursor(Releasing the work area) are the steps involved when using
explicit cursors.
There
are three modes for passing parameters to subprograms 1.IN - An
In-parameter lets you pass values to the subprogram being called. In
the subprogram it acts like a constant and cannot be assigned a
value. 2. OUT – An out-parameter lets you return values to the
caller of the subprogram. It acts like an initialized variable its
value cannot be assigned to another variable or to itself. 3.INOUT –
An in-out parameter lets you pass initial values to the subprogram
being called and returns updated values to the caller.
1.Truncate
– Data truncated by using truncate statement is lost permanently
and cannot be retrieved even by rollback. Truncate command does not
use rollback segment during its execution, hence it is fast. 2.
Delete – Data deleted by using the delete statement can be
retrieved back by Rollback. Delete statement does not free up the
table object allocated space.
- 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 1.Pre-Defined – Predefined by PL/SQL and are
associated with specific error codes. 2.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.
Pragma
Exception_Init is used to handle undefined exceptions. It issues a
directive to the compiler asking it to associate an exception to the
oracle error. There by displaying a specific error message pertaining
to the error occurred. Pragma Exception_Init (exception_name,
oracle_error_name).
1.A
package is a database objects that logically groups related PL/SQL
types, objects, and Subprograms. 2.Procedure is a sub program written
to perform a set of actions and can return multiple values.
3.Function is a subprogram written to perform certain computations
and return a single value. Unlike subprograms packages cannot be
called, passed parameters or nested.
Anonymous
Block is a block of instructions in PL/SQL and SQL which is not saved
under a name as an object in database schema It is also not compiled
and saved in server storage, so it needs to be parsed and executed
each time it is run. However, this simple form of program can use
variables, can have flow of control logic, can return query results
into variables and can prompt the user for input using the SQL*Plus
'&' feature as any stored procedure.
Trigger
is a procedure that gets implicitly executed when an
insert/update/delete statement is issued against an associated table.
Triggers can only be defined on tables not on views, how ever
triggers on the base table of a view are fired if an
insert/update/delete statement is issued against a view. There are
two types of triggers, Statement level trigger and Row level trigger.
Insert After / For each row Trigger is fired / Update / Before / For
Each statement Delete.
Commit
– Makes changes to the current transaction permanent. It Erases the
savepoints and releases the transaction locks. Savepoint –Savepoints
allow to arbitrarily hold work at any point of time with option of
later committing. They are used to divide transactions into smaller
portions. Rollback – This statement is used to undo work.
DDL
statements are used for defining data. Ex: Create, Alter,
Drop,Truncate,Rename. DML statements are used for manipulating data.
Ex: Insert, update, truncate. DCL statements are used for to control
the access of data. Ex; Grant, Revoke. TCL statements are used for
data saving.Ex; Commit,Rollback,Savepoint.
- What is the difference between the snapshot and synonym?7 A snapshot refers to read-only copies of a master table or tables located on a remote node. A snapshot can be queried, but not updated; only the master table can be updated. A snapshot is periodically refreshed to reflect changes made to the master table. In this sense, a snapshot is really a view with periodicity. 8 A synonym is an alias for table, view, sequence or program unit. They are of two types private and public.
1..Procedure
is a sub program written to perform a set of actions and returns
multiple valuesUsing out parameters or return no value at all.
2..Function is a subprogram written to perform certain computations
and return a single value.
Queries
can be tuned by Checking the logic (table joins), by creating Indexes
on objects in the where clause, by avoiding full table scans. Finally
use the trace utility to generate the trace file, use the TK-Prof
utility to generate a statistical analysis about the query using
which appropriate actions can be taken.
Char
reserves the number of memory locations mentioned in the variable
declarations, even though not used (it can store a maximum of 255
bytes). Where as Varchar does not reserve any memory locations when
the variable is declared, it stores the values only after they are
assigned (it can store a maximum of 32767 bytes).
All
tables are multi-org tables which are associated with the company as
a whole. Multiple Organizations is enabled in Oracle Applications by
partitioning some database tables by the Operating Unit. Other tables
are shared across Operating Units (and therefore across set of
books). Examples of Applications with partitioned tables are Oracle
Payables, Oracle Purchasing, Oracle Receivables, Oracle Projects,
Oracle Sales & Marketing etc. The name of each corresponding
partitioned table is.
A
mutating table is a table that is currently being modified by an
UPDATE, DELETE, or INSERT statement, or it is a table that might need
to be updated by the effects of a declarative DELETE CASCADE
referential integrity constraint. A mutating error occurs when a
trigger which fires when updation/deletion/insertion is done on a
table A performs insertion/updation/deletion on the same table A.
This error results in an infinite loop which is termed as a mutating
error.
Data
Cleaning: Transformation of data in its current state to a
pre-defined, standardized format using packaged software or program
modules. Data Testing: The agreed upon conversion deliverables should
be approved by the client representatives who are responsible for the
success of the conversion. In addition, three levels of conversion
testing have been identified and described in the prepare conversion
test plans deliverables. Eg: for Summary Balances in GL we set Test
Criteria as Record Counts, Hash Totals, Balances, Journal Debit and
Credit.
Hello,
ReplyDeleteTOP 20 PL SQL INTERVIEW QUESTION being contrived to exist for many projects simply so it can be run will be the first to hit the wall, but those projects where the functions to make existing transactions cheaper in real world applications will find the elusive real world demand.
I am trying to use this in a materialized view and got below error:
SQL Error: ORA-12015: cannot create a fast refresh materialized view from a complex query
12015. 00000 - "cannot create a fast refresh materialized view from a complex query"
*Cause: Neither ROWIDs and nor primary key constraints are supported for
complex queries.
*Action: Reissue the command with the REFRESH FORCE or REFRESH COMPLETE
option or create a simple materialized view.
select IR.rowid MV_INST_LOBR_ROWID, J.rowid Job_ROWID, J.* FROM JOB J
LEFT JOIN MV_INST_LOB_R IR ON
(IR.I1503_CUST_AC_NO_PT1 = J.I3200_CUST_AC_NO_PT1 AND IR.I1503_CUST_AC_NO_PT2 = J.I3200_CUST_AC_NO_PT2 AND IR.I1503_INST_SEQ_NO = J.I3200_INST_SEQ_NO)
WHERE IR.I1503_CUST_AC_NO_PT1 IS NOT NULL AND IR.I1503_CUST_AC_NO_PT2 IS NOT NULL
UNION SELECT null, J.rowid Job_ROWID, J.* FROM JOB J WHERE J.I3200_CUST_AC_NO_PT1 IS NULL AND J.I3200_CUST_AC_NO_PT1 IS NULL;
Basically, the intention is to get all the records joining MV_INST_LOB_R and JOB table
where MV_INST_LOB_R do not have record for the joining condition J.I3200_CUST_AC_NO_PT1 / J.I3200_CUST_AC_NO_PT2
Can you help me in converting to simple query, so that I can use simple materialized view.
Follow my new blog if you interested in just tag along me in any social media platforms!
,Merci
Hello There,
ReplyDeleteFully agree on TOP 20 PL SQL INTERVIEW QUESTION . We’re seeing a lot of projects tackle big complex problems but few seem to have taken into consideration and in particular reasons to adopt.
I want to execute the different files at the run time in the SQL PLUS
Ex: I have two different files like ABC.SQL, XYZ.SQL,
I had declared one bind variable to hold file_name .
var file_name VARCHAR2(200);
DECLARE
sr VARCHAR2(20) :='ABC';
BEGIN
IF sr ='ABC' THEN
:file_name :='ABC.SQL';
ELSE
:file_name :='XYZ.SQL';
END IF;
END;
/
PRINT file_name
Now i want to execute the file which is there in :file_name bind variable
SQL>@:file_name
It was cool to see your article pop up in my google search for the process yesterday. Great Guide.
Keep up the good work!
Obrigado,
Preethi.
This comment has been removed by the author.
ReplyDelete