My INSURER PTE LTD - Insurtech Innovation Award 2024
Top MNC'S Interview questions and answers
1. 1. Introduce yourself
2. Difference betweenhavingandgroup by
HAVINGisonlyfor conditionsinvolvingaggregatesusedinconjunctionwiththe GROUPBY
clause.eg.COUNT,SUM, AVG,MAX, MIN.WHERE isfor any non-aggregage conditions.
Theycan evenbe usedtogetherinthe same query
. SELECT t1.id, COUNT (*) FROMtable1AS t1
INNERJOIN table2AS t2 ON t2.t1_id = t1.id
WHERE t1.score > 50
GROUP BY t1.idHAVINGCOUNT (*) > 2;
3. Whatis IN parameter and OUT parameter in PLSQL?
1. IN - The parametercan be referencedbythe procedure orfunction.The value of the
parametercan notbe overwrittenbythe procedure orfunction.
2. OUT - The parametercannot be referencedbythe procedure orfunction,butthe value
of the parametercan be overwrittenbythe procedure orfunction.
3. IN OUT - The parametercan be referencedbythe procedure orfunctionandthe value
of the parametercan be overwrittenbythe procedure orfunction.
4. Difference betweenValue setsandLookups
Value setsand Lookupsmightlooksimilarandconfuse some people butthere are some
basicdifferencesbetweenthe two.
Value Sets Lookups
Value sets canbe attachedto parameters
of a concurrentprogram.
Lookups can n’t be attachedto
parametersof a concurrentprogram.
Value Setsare almostnevermaintained
by endusers,withthe exceptionof GL
Flex field codes. Lookupsare maintainablebythe users.
Value setsare usuallymaintainedby
SystemAdministrators.
HR Users will maintain"EthnicMinority"
lookups.
Value setscancontainvaluesthatare a
resultof an SQL Statement.Hence itis
possible tomake Value Setlistof values
dynamic.
2. 5. How we can eliminate duplicateswithoutusingdistinct command?
DELETE FROMempWHERE rowidIN(SELECTeno,ename,sal,max(rowid) FROMemp
GROUP BY eno,ename,sal);
6. How to retrieve a second highestsalary from a table?
SelectMax(Salary) fromEmpWhere Salary< (SelectMax(Salary) fromEmp).
7. Difference betweencase anddecode
DECODE is Oracle standardand CASEis ANSIstandard
Both CASEand DECODE can be usedinWHERE clause.
CASE can be directlyusedinPL/SQLbutDECODE can be usedinPL/SQL throughSQL
statementsonly.
Case cannot processnull while decode can.
8. The two differenttypesofExceptionsin PL/SQL are: ?
User Defined
Pre-Defined
9. Cursor attributes:
There are five cursorattributes:
%isopen
%found
%notfound
%rowcount
%bulk_rowcount
10. What is %TYPE and %ROWTYPEin PL/SQL??
%TYPE providesthe datatype of a variable ora database columntothat variable.
%ROWTYPE providesthe recordtype thatrepresentsaentire row of a table or view or
columnsselectedinthe cursor.
3. Ex:- DECLARE
l_rec employee%rowtype;
CURSOR c1
IS
SELECT * FROM employee WHERE empno = 100;
BEGIN
OPEN c1;
FETCH c1 INTO l_rec;
CLOSE c1;
END;
11. List all differenttypesofData Types in PL/SQL?
Here are the complete lists of DataTypessupportedbyOracle
NumberData Types
BINARY_INTEGER
NUMBER(p,s)
NATURAL
NATURALN
PLS_INTERGER
POSITIVE
POSITIVEN
SIGNTYPE
NUMERIC(p,s)
FLOAT
DEC(p,s)
DECIMAL(p,s)
INTEGER
INT
SMALLINT
REAL
DOUBLE PRECISION
4. 12.Types of Report Triggers:-
a) ReportTrigger:Orderof Executionof ReportTriggeris,
· Before Parameterformtriggerisfired
· AfterParameterformtriggerisfired
· Before ReportTriggerisfired
· Betweenpagesfiresforeachpage exceptlastone
· AfterReporttriggerisfired
13.What isdifference betweenaPROCEDURE & a FUNCTION?
Functionismainlyusedinthe case where itmustreturna value.Where asa procedure
may or may notreturna value ormay returnmore than one value usingthe OUT
parameter.
14. What is difference between%ROWTYPEand TYPE RECORD?
Advantages:
% ROWTYPE isto be usedwheneverqueryreturnsaentire row of a table or view.
TYPE rec RECORD is to be usedwheneverqueryreturnscolumnsof differenttable or
viewsandvariables.
Example:
TYPE r_emp IS RECORD (enoemp.empno% type,enameempename %type
);
e_rec emp%ROWTYPE
cursor c1 isSELECT empno,deptnoFROMemp;
e_rec c1 %ROWTYPE.
15. Can you have multiple layouttemplatesfor a singe data template?
Yes!Multiple layoutscanbe attached,so thatuser will have achoice here touse one
amongthemat the time of concurrentprogram submission
DECODE is a functionwhere CASEisa Expression.
16. What is burstingin XML Publisher?
What are the differentwaystoshow/insertanimage onXMLP layout?
There are 4 differentwaystoinsert/show animage inrtf:
Insertan image directlyonrtf justby usingMS word standardfeature
UsingOA_MEDIA: storingon serverandgivingphysical pathof the image
UsingURL of a image hostedonsome website
5. Retrievingthe image store inadatabase as BLOB type
17. Difference betweendelete andtruncate
You cann't rollbackinTRUNCATE but inDELETE you can rollback.TRUNCATEremovesthe
record permanently.
In case of TRUNCATE,Trigger doesn'tgetfired. ButinDML commandslike DELETE Trigger
getfired.
You cann't use conditions(WHEREclause) inTRUNCATE.ButinDELETE youcan write
conditionsusingWHEREclause
18. How many typesof indexes
We have mainlytwodifferentindexes.
Implicitindexandexplicitindex.
Explicitindexesare againof manytypeslike
simple index,unique index,Bitmapindex,Functional
index,Organisationalindex,clusterindex.
19. What is trigger?How many typesof Trigger are there?
Triggeris a procedure th getsimplicitlyexecutedwhenaninsert/update/deletestatement
isissuedagainstanassociated
table.Triggerscan onlybe definedontablesnotnoviews, howevertriggersonthe base
table of a vieware firedif an
..0Insert/update/deletestatementisissuedagainstaview .there are two typesof triggers
stamentlevel andRowleveltrigger
Insert
After/Foreach row
Triggeris fire /update/Befor/foreachstatementdelete
20. Diff b/w viewand materializedview
Materializedviewisphysical duplicatedataina table
viewislogical representationof table
6. 21. Can we update the view
Suppose youwantupdate viewmeansthattime youneedtouse instedof triggerwith
that onlypossible toupdate view
22. I have one table i created viewand materializedviewon a table ifi delete a
table,Can i see the viewand materializedview?
23. Can u call function in same function
Yes
24.Can we use tcl commands in trigger
Nope,youcannot.
25. What is the cursor and ref cursor
Generallyref cursorusedforpassingcursorparameterand alsodynamicallybuildingthe
query.
Normal cursor are static cursors andalso we can't able to passlike parameters
26. What is the purpose of Tokenin Concurrent Program Definitionform?
Tokenisusedfor transferringvaluestowardsreportbuilder.Tokensare usuallynotcase –
sensitive.
27. Formula column
We use formulacolumn tocalculate some informationdynamically usinginformation
basedon the columnsof the data model orfrom the concurrentprogram parameters.Itis
basicallyusedtoapplysome customlogiconinputdata and returnsome value.
Formulacolumnscan be writtenusingPL/SQLsyntax andwe can use pl/sql functionsfor
computationonthe data. Formulacolumnwill acceptdataof Character, Number,orDate
type.
Ex:- CF_
28. Summary column:-
Summarycolumnsare usedfor calculatingsummaryinformationlike sum, average etc,.
on specificcolumnsof adata group. This columnusesa setof predefinedoracle
7. aggregate functions.Summarycolumnsare generallyprecededbyCS_to distinguishthem
fromothercolumns.
29. To fetchALTERNATE records from a table.(EVEN NUMBERED)
select* fromempwhere rowidin(selectdecode(mod(rownum,2),0,rowid,null)from
emp);
30. To selectALTERNATE records from a table.(ODD NUMBERED)
select* fromempwhere rowidin(selectdecode(mod(rownum,2),0,null,rowid)from
emp);
31. Find the 3rd MAX salary inthe emp table.
selectdistinctsal fromempe1where 3 = (selectcount(distinctsal) from empe2where
e1.sal <= e2.sal);
32. Find the 3rd MIN salary in the emptable.
selectdistinctsal fromempe1where 3 = (selectcount(distinctsal) fromempe2where
e1.sal >= e2.sal);
33. SelectFIRST n recordsfrom a table.
select* fromempwhere rownum <= &n;
34. SelectLAST n records from a table
select* fromempminusselect* fromempwhere rownum<= (selectcount(*) - &nfrom
emp);
35. List dept no., Deptname for all the departmentsin whichthere are no employeesin
the department.
select* fromdeptwhere deptnonotin(selectdeptnofromemp);
alternate solution: select*fromdepta where notexists(select*from empb where
a.deptno= b.deptno);
altertnate solution: selectempno,ename,b.deptno,dname fromempa,deptbwhere
a.deptno(+) =b.deptnoandempnoisnull;
36. How to get 3 Max salaries ?
selectdistinctsal fromempa where 3 >= (selectcount(distinctsal) fromempbwhere
a.sal <= b.sal) orderbya.sal desc;
8. 37. How to get 3 Min salaries?
selectdistinctsal fromempa where 3 >= (selectcount(distinctsal) fromempb where
a.sal >= b.sal);
38. How to get nth max salaries?
selectdistincthiredatefromempawhere &n = (selectcount(distinctsal) fromempb
where a.sal >= b.sal);
39. SelectDISTINCT RECORDS from emp table.
select* fromempa where rowid=(selectmax(rowid) fromempbwhere
a.empno=b.empno);
40. How to delete duplicate rowsin a table?
delete fromempawhere rowid!=(selectmax(rowid) fromempbwhere
a.empno=b.empno);
41. Count of numberof employees in department wise.
selectcount(EMPNO),b.deptno,dname fromempa,deptb where a.deptno(+)=b.deptno
groupby b.deptno,dname;
42. Suppose there isannual salary informationprovidedby emp table.How to fetch
monthly salary of each and everyemployee?
selectename,sal/12asmonthlysal fromemp;
43. Selectall record from emptable where deptno=10 or 40.
select* fromemp where deptno=30ordeptno=10;
44. Selectall record from emptable where deptno=30 and sal>1500.
select* fromemp where deptno=30andsal>1500;
45. Select all record from emp where job not in SALESMAN or CLERK.
select*from empwhere jobnotin('SALESMAN','CLERK');
9. 46. Selectall record from empwhere ename in'BLAKE','SCOTT','KING'and'FORD'.
select*from emp where ename in('JONES','BLAKE','SCOTT','KING','FORD');
47. Selectall records where ename starts with‘S’ and its lenth is6 char.
select* fromemp where ename like'S____';
48. Selectall records where ename may be any no of character but it shouldendwith
‘R’.
select* fromemp where ename like'%R';
49. Count MGR and their salary in emp table.
selectcount(MGR),count(sal) fromemp;
50. In emp table add comm+sal as total sal .
selectename,(sal+nvl(comm,0)) astotalsal fromemp;
51. Select any salary <3000 from emp table.
select* fromemp where sal>any(selectsal fromempwhere sal<3000);
52. Select all salary <3000 from emp table.
select*from emp where sal>all(selectsal fromempwhere sal<3000);
53. Selectall the employee groupby deptnoand sal in descendingorder.
selectename,deptno,salfromemporderbydeptno,sal desc;
10. 54. How can I create an emptytable emp1 withsame structure as emp?
Create table emp1as select*from empwhere 1=2;
55. How to retrive record where sal between1000 to 2000?
Select* fromemp where sal>=1000 And sal<2000
56. Selectall records where deptno ofboth emp and dept table matches.
select*from empwhere exists(select*fromdeptwhere emp.deptno=dept.deptno)
57. If there are two tablesemp1 and emp2, and both have common record. How can I
fetchall the recods but common records onlyonce?
(Select*fromemp) Union(Select*from emp1)
58. How to fetchonly common records from two tablesemp and emp1?
(Select* fromemp) Intersect(Select*fromemp1)
59. How can I retrive all recordsof emp1 those shouldnot presentin emp2?
(Select* fromemp) Minus(Select*fromemp1)
60. Countthe totalsa deptnowise where more than2employeesexist.
SELECT deptno, sum(sal) Astotalsal
FROM emp
GROUP BY deptno
HAVINGCOUNT(empno) >2
60. How can a break order be created on a column in an existinggroup?
By draggingthe columnoutside the group
61. What are the typesof calculated columnsavailable?
11. Summary, Formula,Placeholdercolumn.
62. What is the use of place holdercolumn?
A placeholdercolumnisusedtoholda calculatedvaluesata specifiedplace ratherthan
allowingistoappearinthe actual row where ithasto appeared.
63. What is the use of hiddencolumn?
A hiddencolumnisusedtowhenacolumnhas to embedintoboilerplatetext.
64. What is the use of break group?
A breakgroupis usedto displayone recordforone groupones.While multiple related
recordsin othergroupcan be displayed.
67. If two groups are not linkedinthe data model editor, what is the hierarchybetween
them?
Two groupthat is above are the leftmostrank higherthanthe group that isto rightor
belowit.
68. The joindefinedbythe defaultdata linkis an outerjoin yesor no?
Yes.
69. How can a textfile be attached to a reportwhile creating in the reportwriter?
By usingthe linkfile propertyinthe layoutboilerplate propertysheet.
70. Can a repeatingframe be created withouta data group as a base?
No.
71. Can a fieldbe usedin a report withoutit appearing in any data group?
Yes.
72. For a fieldina repeatingframe,can the source come from the column which does
not existin the data group whichforms the base for the frame?
Yes.
73. Is it possible to centre an objecthorizontallyin a repeatingframe that has a variable
horizontal size?
Yes.
74. If yes,how?
12. By the use anchors.
75. What are the two repeatingframe always associatedwith matrix object?
One downrepeatingframe below one acrossrepeatingframe.
76. Is it possible to splitthe print previewerintomore than one region?
Yes.
77. Does a grouping done for objects inthe layout editoraffect the grouping done in the
data model editor?
No.
78. How can a square be drawn in the layout editorof the report writer?
By usingthe rectangle tool while pressingthe (Constraint) key.
79. To displaythe page no. for each page on a report what would be the source & logical
page no. or & of physical page no.?
& physical page no.
80. What doesthe term panel referto withregard to pages?
A panel isthe no.of physical pagesneededtoprintone logical page.
81. What is an anchoring object & what isits use?
An anchoringobjectisa printconditionobjectwhichusedtoexplicitlyorimplicitlyanchor
otherobjectsto itself.
82. What is a physical page?& what is a logical page?
A physical page isa size of a page.That is outputby the printer.The logical page isthe size
of one page of the actual reportas seeninthe Previewer.
83. What is the frame & repeatingframe?
A frame isa holderfora groupof fields.A repeatingframe isusedtodisplayasetof
recordswhenthe no.of recordsthat are to displayedisnotknownbefore.
84. What is SQLCODE and SQLERRM inPL/SQL?
The SQLCODE functionreturnsthe errornumberassociatedwiththe mostrecentlyraised
error exception.Thisfunctionshouldonlybe usedwithinthe ExceptionHandlingsection
of yourcode.
13. The SQLERRM functionreturnsthe errormessage associatedwiththe mostrecently
raisederrorexception.Thisfunctionshouldonlybe usedwithinthe ExceptionHandling
sectionof yourcode.
IBM PLSQL InterviewQuestion
Can we use where conditionwith truncate?
No, TRUNCATE is all or nothing.Youcan do a DELETE FROM <table>WHERE
<conditions>butthislosesthe speedadvantagesof TRUNCATE.
Can you explainthe truncate and delete withtrigger?
DELETE
Delete isthe commandthatonlyremove the datafrom the table.Itis DML statement.
Deleteddatacan be rollback. Byusingthiswe can delete wholedatafromthe table(if use
withoutwhere clause). If youwantto remove onlyselecteddatathenwe shouldspecify
conditioninthe where clause
delete fromemployee ;( this commandwill remove all the datafromtable)
delete fromemployee where employee name='JOHN';(Thiscommandwill remove only
that row fromemployeetable where employee_name isJOHN');
DROP:
Drop commandremove the table fromdatadictionary.Thisisthe DDL statement.We can
not recoverthe table before Oracle 10g.But Oracle 10g provide the commandtorecover
it byusingthe command(FLASHBACK)
TRUNCATE:
Thisis the DML command.Thiscommanddelete the datafromtable.Butthere isone
difference fromordinarydelete command.Truncate commanddropthe storage heldby
thistable.Dropstorage can be usedbythistable againor some othertable.Thisisthe
fastercommandbecause itdirectlydropthe storage
4>In case of TRUNCATE,Triggerdoesn'tgetfired.Butin DML commandslike DELETE
.Triggergetfired.
5>you cann't use conditions(WHEREclause) in TRUNCATE.But in DELETE youcan write
conditionsusingWHEREclause
Can we use truncate and delete commandto disable the referential integrityconstraint?
14. > Firsttime asker,longtime reader! My question:
I wishto delete all recordsfromaparenttable and all recordsfroma childtable.
If I delete fromfromthe childtable thendeletefromthe parent,
Everythingworksfine. Butif I truncate the childtable,thentryto
truncate the parent, I getan error:
> ERROR at line 1:
> ORA-02266: unique/primarykeysintable referencedbyenabledforeignkeys
> Do youhave insightintothis?
Differencesbetweenthe DELETE commandand the TRUNCATE command.
DELETE removesone ormore records ina table,checkingreferential
Constraints(tosee if there are dependentchildrecords) andfiringany
DELETE triggers.Inthe orderyouare deleting(childfirstthenparent)
There will be noproblems.
TRUNCATE removesALLrecordsin a table.Itdoesnot execute anytriggers.
Also,itonlychecksforthe existence (andstatus) of anotherforeignkey
Pointingtothe table.If one existsandisenabled,thenyouwill get
Your error.This istrue evenif youdothe childtablesfirst.
You shoulddisable the foreign keyconstraintsinthe childtablesbefore
Issuingthe TRUNCATEcommand,thenre-enable themafterwards.
15. How did you export the data from database to excel file?
How many typesof functionsin UTL_FILE package?
Withthe Oracle-suppliedUTL_FILEpackage,youcan read fromand write tooperatingsystem
files.ItProvidessecurityfordirectoriesonthe throughthe init.Orafile.UTL_FILEProcedures
and Functions:
• FunctionFOPEN
• FunctionIS_OPEN
• Procedure GET_LINE
• Procedure PUT,PUT_LINE, PUTF
• Procedure NEW_LINE
• Procedure FFLUSH
• Procedure FCLOSE,FCLOSE_ALL
What functionyou are using to load the data in UTL_FILE package?
IntroducedinOracle 7.3, UTL_FILE PL/SQLpackage providesafunctionalityof readingand
writingtextfile into operatingsystemfiles.Thatmeansyoucanloadexternal datafromother
source to database or can generate reportfromyourPL/SQL code and write totextfile on
operatingsystem.
UTL_FILE package provides access to text file on the OS of the database server. You can use
one of the following approaches to restrict access to text file from database server.
Use the UTL_FILE_DIR parameterin init.orainitializationfile tospecifythe
accessible directoryforthe UTL_FILE functionstoread or write operation
UTL_FILE_DIR ='E:appmadhurendrawr_file'
Use the CREATE DIRECTORY statement[ORACLE9i or above]toassociate an
operatingsystemdirectorywithaliastoprovide read/write operation
CREATE DIRECTORY my_demo_dirAS 'E:appmadhurendrawr_file';
GRANT READ,WRITE ON DIRECTORY my_demo_dirTOuser$plsql;
Followingsare some procedures,functionsandexceptionsof the UTL_FILE package.
DATA TYPE
FILE_TYPE Data type fora file-handle
PROCEDURES & FUCTIONS
IS_OPEN Checkswhetherfile isopenornot.ReturnsTRUE if openandFALSE if close.
FOPEN Opensa file forreador write.
FCLOSE Closesan openfile
FCLOSE_ALL Closesall openfile forthe currentsession
NEW_LINE Inserta newline terminatortoa file
PUT_LINE Write stringsof textfollowedbyanew line terminator
PUT Same as PUT_LINE butdon’tplace a new line terminator.
PUTF Writesformattedtextintofile
GET_LINE Reada line fromfile.The maximumoutput
FFLUSH Writesall the buffereddataintofile
EXCEPTIONS
INVALID_PATH File locationisnotvalid
16. INVALID_MODE
OPEN_FILE mode isnot valid. [SpecifictoFOPEN]
INVALID_FILENAME Filename isnotvalid
READ_ERROR Operatingsystemerroroccurredduringthe readoperation.
WRITE_ERROR Operatingsystemerroroccurredduringthe write operation.
FILE_OPEN Operationfailedbecausethe fileisalreadyopen.
These exceptionsmustbe prefixedwithUTL_FILE.Apart fromthat UTL_FILE can also raise
pre-definedexceptionslikeNO_DATA_FOUNDandVALUE_ERROR.
Followingsare a couple of verysimple example of UTL_FILE package:
In the followinganonymousblock,dataiswrittenbyUTL_FILE package to a text
file ‘my_f_file.txt’.
DECLARE
v_file UTL_FILE.FILE_TYPE;
BEGIN
v_file :=UTL_FILE.FOPEN('MY_DEMO_DIR', 'my_f_file.txt','w');
UTL_FILE.PUT_LINE(v_file, 'HelloWorld!');
UTL_FILE.PUT_LINE(v_file,'IstaredusingUTL_FILE');
UTL_FILE.FCLOSE(v_file);
END;
How many typesof trigger?
BEFORE UPDATE, StatementLevel
BEFORE UPDATE, Row Level
AFTER UPDATE, StatementLevel
AFTER UPDATE, RowLevel
How many max triggers you will declare what isinstead oftrigger?
You can create N numbersof triggersona table butthe maximumpossibletypestriggercan
be appliedis3*2*2=12
(Insert/Update/Delete=3,before/after=2,Row Level/StatementLevel=2)
What is implicitand explicitcursor?
PL/SQL declaresacursor implicitlyforall SQLdata manipulationstatements,includingquries
that returnonlyone row.However,queriesthatreturnmore thanone row you mustdeclare
an explicitcursororuse a cursor FOR loop.
Explicitcursorisa cursor in whichthe cursor name isexplicitlyassignedtoaSELECT
statementviathe CURSOR...ISstatement.Animplicitcursorisusedforall SQL statements
Declare,Open,Fetch,Close.Anexplicitcursorsare usedtoprocessmulti row SELECT
statementsAnimplicitcursorisusedto processINSERT,UPDATE,DELETE andsingle row
SELECT. .INTOstatements.
17. What is exception?
PL/SQL providesafeature tohandle the Exceptionswhichoccurina PL/SQL Blockknownas
exceptionHandling.UsingExceptionHandlingwe cantestthe code and avoidit fromexiting
abruptly.
Whenan exceptionoccursmessageswhichexplainsitscause isreceived.
PL/SQL Exceptionmessageconsistsof three parts.
1) Type of Exception
2) An Error Code
3) A message
How many typesof exceptionCan we have more than one exception?
Typesof Exception.
There are 3 typesof Exceptions.
a) NamedSystemExceptions
b) UnnamedSystemExceptions
c) User-definedExceptions
DECLARE
--<Declaration section >
BEGIN
--<logic>
EXCEPTION
WHEN ex_name1THEN
-Error handlingstatements
WHEN ex_name2THEN
-Error handlingstatements
WHEN OthersTHEN
-Error handlingstatements
END;
What are predefinedexceptions?
PL/SQL providesmanypre-definedexceptions,whichare executedwhenanydatabase rule is
violatedbyaprogram. For example,the predefinedexceptionNO_DATA_FOUNDisraised
whena SELECT INTO statementreturnsnorows.The followingtable listsfew of the
importantpre-definedexceptions:
Exception Oracle
Error
SQLCODE Description
ACCESS_INTO_NULL 06530 -6530 It israisedwhena null objectis
automaticallyassignedavalue.
18. CASE_NOT_FOUND 06592 -6592 It israisedwhennone of the choicesin
the WHEN clausesof a CASEstatementis
selected,andthere isnoELSE clause.
COLLECTION_IS_NULL 06531 -6531 It israisedwhena programattemptsto
applycollectionmethodsotherthan
EXISTSto an uninitializednestedtable or
varray, or the program attemptsto assign
valuestothe elementsof anuninitialized
nestedtable orvarray.
DUP_VAL_ON_INDEX 00001 -1 It israisedwhenduplicate valuesare
attemptedtobe storedina columnwith
unique index.
INVALID_CURSOR 01001 -1001 It israisedwhenattemptsare made to
make a cursor operationthatis not
allowed,suchasclosinganunopened
cursor.
INVALID_NUMBER 01722 -1722 It israisedwhenthe conversionof a
character stringintoa numberfails
because the stringdoesnotrepresenta
validnumber.
LOGIN_DENIED 01017 -1017 It israisedwhens programattemptsto
logon to the database withan invalid
username orpassword.
NO_DATA_FOUND 01403 +100 It israisedwhena SELECT INTO
statementreturnsnorows.
NOT_LOGGED_ON 01012 -1012 It israisedwhena database call isissued
withoutbeingconnectedtothe database.
PROGRAM_ERROR 06501 -6501 It israisedwhenPL/SQLhas an internal
problem.
ROWTYPE_MISMATCH 06504 -6504 It israisedwhena cursor fetchesvalue in
a variable havingincompatibledata type.
19. SELF_IS_NULL 30625 -30625 It israisedwhena membermethodis
invoked,butthe instance of the object
type wasnot initialized.
STORAGE_ERROR 06500 -6500 It israisedwhenPL/SQLran out of
memoryor memorywascorrupted.
TOO_MANY_ROWS 01422 -1422 It israisedwhens SELECT INTOstatement
returnsmore than one row.
VALUE_ERROR 06502 -6502 It israisedwhenan arithmetic,
conversion,truncation,orsize-constraint
error occurs.
ZERO_DIVIDE 01476 1476 It israisedwhenan attemptismade to
divide anumberbyzero.
Do you know TOO_MANYROWS, whenthat exceptionwill occur and NO_DATA FOUND
How to catch any type of exception?
DECLARE
v_drop_partition VARCHAR2(1) :=NULL;
BEGIN
SELECT drop_partition
INTOv_drop_partition
FROM xxx.part_maint
WHERE drop_partition = 'Y'
;
FOR prec IN (SELECT * FROM xxx.part_maintWHEREdrop_partition ='Y' )
LOOP
DBMS_OUTPUT.PUT_LINE (prec.SCHEMA_NAME||' ' || prec.OBJECT_NAME);
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUNDTHEN
DBMS_OUTPUT.PUT_LINE ('hello');
END;
Can we commit in trigger?
20. Yes,You can Commitinside the trigger.
But for thisyouhave to make thistriggertransactionto be a Independenttransaction from
itsparenttransaction,You can do thisby usingPragma.Pragma
AUTONOMOUS_TRANSACTION allowyoutobuildthe Independent(child) Transaction,
startedby another.Sholdbe declare inDECLAREsectionof any subprogram.
Usedto make Modular and Reusable Blocks.if youneedthe examplethenasktome.
CREATE OR REPLACE TRIGGER trigger
AFTER INSERTON t1 FOREACH ROW
DECLARE
PRAGMA AUTONOMOUS_TRANSACTION;
i PLS_INTEGER;
BEGIN
SELECT COUNT(*)
INTOi
FROMt1;
INSERTINTOt2
VALUES
(i);
COMMIT;
END;
What is autonomoustransaction?
An autonomoustransactionisanindependenttransactiontothe mainor parenttransaction.
If an Autonomous transactionisstartedbyanothertransactionitisnotnested,
but independentof parenttransaction.
CREATE OR REPLACE PROCEDURE childblock IS
BEGIN
INSERTINTOt
21. (testvalue)
VALUES
('Childblockinsert');
COMMIT;
END child_block;
What is view?
An Oracle VIEW,inessence,isavirtual table thatdoesnot physicallyexist.Rather,itis
createdby a query joiningone ormore tables.
CREATE VIEW viewname AS
SELECT columns
FROMtables
[WHERE conditions];
Can we delete arecord in view?
Can we delete a record more than one table?
DELETE FROMusession
WHERE session_id=(SELECTsession_id
FROM usession
WHERE delete_session_idISNULL
ANDuser_id= (SELECT user_id
FROM users
WHERE REGEXP_LIKE(USER_NAME,
'awpeople','i')));
22. Can we write triggeron view?
Create triggertri_account
Before insertorupdate
on account
for eachrow
Begin
IF (:new.acct_id=2 and :new.cust_id=23) THEN
raise_application_error( -20001, 'Noinsertionwithid2 and23.');
END IF;
end;
Do you have use any debuggingtool?
Do you know global variable,difference betweenglobal variable andparameter variable?
Well,basically,aglobal variableisa variable thatcan be used anywhere. Butlocal variable is
a variable thatcan be usedinwithinsub programs.
Do you know about cascading triggers?
Whena statementina triggerbodycauses anothertriggerto be fired,the triggersare saidto
be cascading.Max = 32.
a) Commiting: A transactionissaid to be commitedwhenthe transactionmakespermanent
changesresultingfromthe SQLstatements.
b) Rollback : A transactionthat retractsany of the changesresultingfromSQLstatementsin
Transaction.
c) SavePoint: For longtransactionsthat containmanySQL statements,intermediate markers
or savepointsare declared.Savepointscanbe usedtodivide atransactinointosmaller
points.d) RollingForward:: Processof applyingredologduringrecoveryiscalledrolling
forward.
What are Database Triggers and StoredProcedures?
Database Triggers:-Database Triggersare Proceduresthatare automaticallyexecutedasa
resultof insertin,update to,or delete fromtable.Database triggershave the valuesoldand
newto denote the oldvalue inthe table before itisdeletedandthe new indicatedthe new
value thatwill be used.DTare useful forimplementingcomplex businessruleswhichcannot
be enforcedusingthe integrity rules.We canhave the triggeras before triggerorAfter
23. Triggerand at StatementorRow level. e.g.::operations insert,update ,delete 3before ,after
3*2 A total of 6 combinationsAtstatementlevel(onceforthe trigger) orrow level(forevery
execution) 6* 2 A total of 12. Thus a total of 12 combinationsare there andthe restrictionof
usage of 12 triggershasbeenliftedfromOracle 7.3Onwards.Stored Procedures::Stored
Proceduresare Proceduresthatare storedinCompiledforminthe database.The advantage
of usingthe storedproceduresisthatmanyuserscan use the same procedure incompiled
and readyto use format.
CTS PL/SQL InterviewQuestions
Tell me somethingyour self?
What are the activitiesare you doing dailyin your project?
Tell me ratio'sof sql,pl/sql&unix?
Diff b/w primary key& unique key?
Diff b/w primary key& unique key+ not null?
What is the use of views?If table dropped,then what happen view?
What is index?typesof indexes?
Whichfunctionsare not supportedto index?What issave point? Whatis ora-1555?
What are the datatypes avilable inpl/sql,not insql?
What is the main use of %type,%rowtype?Whatiscursor? Typesof cursors?
Diff b/w explictcursor & for loop cursor?
What is exception?
Types of exceptions?
What is raise_application_error?
What is pragma_exception_init?
Diffb/w triggers&procedures?Canyou call procedure inselectstatement?Restrictionsin
functions?
What is the use of packages?How to drop package body only? Can use
pragma_autonamous_tranctions in packages?
What is bulk collect?Whatis nullif()?Whatismutating error?
24. What are the module's,you are working Whichwill fire defaultfirst statementlevel or row
level trigger?
What is bulkcollect?Andany restrictionsin bulkcollect?Whatis the use of limitclause in
bulkcollect?
How to debuggyour code? How to trace error handling?
How to findwhich line error was raised?
What are the methodsthere in save exceptions?
What is functional basedindex?Write syntax?
How to update complexview?Can you alter procedure with in package? Is it possible to
opencursor which isin package in another procrdure?
What is substr()&instr()?Difference betweencase anddecode?Can you use sysdate in
check constraints? If no,why?
Difference betweencolumnlevel constraints& table level constraints?What is optimizer?
What is nested_loopjoin?Whatis pivotoperater? Tell me some oracle 10g features?
What is m_view?What ismaster & detail tables?What is sqlcode and sqlerrm?
Diffb/w procedure & packages? Whatare the dis_adv of packages? Tell me some strong
pointsin your boss?
What is Profile?ExplaindifferentlevelsofProfile?
A userprofile isasetof changeable optionsthataffectsthe wayyourapplicationsrun.Oracle
ApplicationObjectLibraryestablishesavalue foreachoptionina user‟s profile whenthe
userlogson or changesresponsibility.Yourusercanchange the value of profile optionsat
any time a) To create Profile Option.( Profile Optioncancreated bydeveloperinapplication
developerarea) b)setthe value (Valuesof the profileoption,whowill have whatvalue at
variouslevelsissetbySYSADMIN).Oracle ApplicationObjectLibraryprovidesmanyoptions
that. (Editprofile feature foreveryuser isavailable tosetanyvalue toallow the user).your
userscan setto alterthe userinterface of yourapplicationstosatisfytheirindividual
preferences.Profile Option –setat run time like –User Related,responsibility, Sequence,
Printer,Security.
Valuesin4 Levels(HIEARCHYWISE) :- USER RESPONSIBILITYAPPLICATION SITEApplication
Developercreate the profile.SystemAdministratormake profileoption.(NOTE:- If any
change in value,itwill active whenyoure-loginorswitchtothe responsibility.)( Usage inthe
multi-tier,the profile isbiggestimpact)
25. Difference betweenViewvsMaterializedViewindatabase?
Based upon on our understanding ofView and Materialized View, Let’s see,some shortdifference
between them :
1) Firstdifference betweenView andmaterializedview isthat,InViewsquery resultisnot
stored inthe disk or database butMaterializedview allow tostore queryresultindiskor
table.
2) Anotherdifference between View vsmaterializedview isthat,whenwe create view using
any table, rowid of viewissame asoriginal table butincase of Materializedview rowidis
different.
3) One more differencebetween View and materialized view in databaseisthat,Incase of
Viewwe alwaysgetlatestdatabutin case of Materializedview we needtorefreshthe view
for gettinglatestdata.
4) Performance of ViewislessthanMaterializedview.
5) Thisis continuationof firstdifference betweenView andMaterializedView,Incase of view
itsonlythe logical viewof table noseparate copyof table but incase of Materializedviewwe
getphysicallyseparate copyof table
6) Last difference betweenView vsMaterializedView isthat,Incase of Materializedview we
needextratriggerorsome automaticmethodsothat we can keepMV refreshed,thisisnot
requiredforviewsindatabase.
TABLE/FIELD FOR SALES ORDER'S SHIP TO LOCATION
selectrsua.locationship_to_location,
raa.ADDRESS1 Ship_To_address1,
raa.ADDRESS2Ship_to_Address2,
raa.address3Ship_to_address3,
raa.country
fromra_site_uses_all rsua,
ra_addresses_all raa,
oe_order_headerS_all oha,
26. wsh_delivery_detailswdd
where wdd.ship_to_site_use_id=rsua.SITE_USE_IDand
oha.order_number='3022004731' and -- SalesOrderNumber
oha.header_id=wdd.source_header_idand
raa.address_id= rsua.address_id
OR
selecta.order_number,d.account_number,e.party_name
fromoe_order_headers_alla,
hz_cust_site_uses_allb, -- usesof customeraddresses
HZ_CUST_ACCT_SITES_ALL c, -- customeraddresses
hz_cust_accountsd, -- customeraccounts
hz_partiese -- parties
where a.ship_to_org_id=b.site_use_id -- ora.invoice_to_org_id
and b.cust_acct_site_id=c.cust_acct_site_id
and c.cust_account_id= d.cust_account_id
and d.party_id= e.party_id;
Joins:
GL AND AP
GL_CODE_COMBINATIONS AP_INVOICES_ALL
code_combination_id = acct_pay_code_combination_id
GL_CODE_COMBINATIONS AP_INVOICES_DISTRIBUTIONS_ALL
code_combination_id = dist_code_combination_id
GL_SETS_OF_BOOKS AP_INVOICES_ALL
set_of_books_id = set_of_books_id
GL AND AR
GL_CODE_COMBINATIONS RA_CUST_TRX_LINE__GL_DIST_ALL
code_combination_id = code_combination_id
27. GL AND INV
GL_CODE_COMBINATIONS MTL_SYSTEM_ITEMS_B
code_combination_id = cost_of_sales_account
GL AND PO
GL_CODE_COMBINATIONS PO_DISTRIBUTIONS_ALL
code_combination_id = code_combination_id
PO AND AP
PO_DISTRIBUTIONS_ALL AP_INVOICE_DISTRIBUTIONS_ALL
Po_distribution_id = po_distribution_id
PO_VENDORS AP_INVOICES_ALL
vendor_id = vendor_id
PO AND SHIPMENTS
PO_HEADERS_ALL RCV_TRANSACTIONS
Po_header_id = po_header_id
PO_DISTRIBUTIONS_ALL RCV_TRANSACTIONS
Po_distribution_id = po_distribution_id
SHIPMENTS AND INVOICE
RCV_TRANSACTIONS AP_INVOICE_DISTRIBUTIONS_ALL
RCV_TRANSACTION_ID = RCV_TRANSACTION_ID
PO AND INV
PO_REQUISITION_LINES_ALL MTL_SYSTEM_ITEMS_B
item_id = inventory_item_id
org_id = organization_id
PO AND HRMS
PO_HEADERS_ALL HR_EMPLOYEES
Agent_id = employee_id
PO AND REQUISITION
PO_DISTRIBUTIONS_ALL PO_REQ_DISTRIBUTIONS_ALL
req_distribution_id = distribution_id
SHIPMENTS AND INV
RCV_TRANSACTIONS MTL_SYSTEM_ITEMS_B
Organization_id = organization_id
INV AND HRMS
28. MTL_SYSTEM_ITEMS_B HR_EMPLOYEES
buyer_id = employee_id
OM AND AR
OE_ORDER_HEADERS_ALL RA_CUSTOMER_TRX_LINES_ALL
TO_CHAR( Order_number) = interface_line_attribute1
OE_ORDER_LINES_ALL RA_CUSTOMER_TRX_LINES_ALL
TO_CHAR(Line_id) = interface_line_attribute6
OE_ORDER_LINES_ALL RA_CUSTOMER_TRX_LINES_ALL
reference_customer_trx_line_id = customer_trx_line_id
OM AND SHIPPING
OE_ORDER_HEADERS_ALL WSH_DELIVARY_DETAILS
HEADER_ID = SOURCE_HEADER_ID
OE_ORDER_HEADERS_ALL WSH_DELIVARY_DETAILS
LINE_ID = SOURCE_LINE_ID
AP AND AR (BANKS)
AR_CASH_RECEIPTS_ALL AP_BANK_ACCOUNTS
REMITTANCE_BANK_ACCOUNT_ID = ABA.BANK_ACCOUNT_ID
AP AND AR
HZ_PARTIES AP_INVOICES_ALL
PARTY_ID = PARTY_ID
OM AND CRM
OE_ORDER_LINES_ALL CSI_ITEM_INSTANCES(Install Base)
LINE_ID = LAST_OE_ORDER_LINE_ID
Po_Requisition_Headers_All
ColumnNames Table Name ColumnName
REQUISITION_HEADER_IDPO_REQUISITION_LINES_ALL REQUISITION_HEADER_ID
TYPE_LOOKUP_CODE PO_DOCUMENT_TYPES DOCUMENT_SUBTYPE
PREPARER_ID PER_PEOPLE_F PERSON_ID
ORG_ID MTL_SYSTEM_ITEMS ORGANIZATION_ID
ORG_ID MTL_ORGANIZATIONS ORGANIZATION_ID
Po_Requisition_Lines_All
ColumnNames Table Name ColumnName
REQUISITION_HEADER_ID PO_REQUISITION_HEADERS_ALL REQUISITION_HEADER_ID
REQUISITION_LINE_ID PO_REQ_DISTRIBUTIONS_ALL REQUISITION_LINE_ID
LINE_TYPE_ID PO_LINE_TYPES LINE_TYPE_ID
ITEM_ID MTL_SYSTEM_ITEMS INVENTORY_ITEM_ID
ORG_ID MTL_SYSTEM_ITEMS ORGANIZATION_ID
30. ACCOUNTING_RULE_ID RA_RULES RULE_ID
PAYMENT_TERM_ID RA_TERMS TERM_ID
SOLD_TO_ORG_ID HZ_CUST_ACCOUNTS CUST_ACCOUNT_ID
SHIP_FROM_ORG_ID MTL_PARAMETERS ORGANIZATION_ID
SHIP_TO_ORG_ID HZ_CUST_SITE_USES_ALL SITE_USE_ID
Oe_Order_Lines_All
ColumnNames Table Name ColumnName
LINE_TYPE_ID OE_TRANSACTION_TYPES_TL TRANSACTION_TYPE_ID
INVOICING_RULE_ID RA_RULES RULE_ID
Hz_Parties
ColumnNames Table Name Column Name
PATY_ID HZ_CUST_ACCOUNTS PATY_ID
CUST_ACCOUNT_ID OE_ORDER_LINES SOLD_TO_ORG_ID
Hz_Party_Sites_All
ColumnNames Table Name Column Name
PATY_ID HZ_PARTIES PATY_ID
LOCATION_ID HZ_LOCATIONS LOCATION_ID
Wsh_delivery_details
ColumnNames Table Name ColumnName
SOURCE_HEADER_ID OE_ORDER_HEADERS SOURCE_HEADER_ID
DELIVERY_DETAIL_ID WSH_DELIVERY_ASSIGNMENTS DELIVERY_DETAIL_ID
DELIVERY_ID WSH_NEW_DELIVERIES DELIVERY_ID
INVENTORY_ITEM_ID MTL_SYSTEM_ITEMS INVENTORY_ITEM_ID
RA_CUSTOMER_TRX_ALL
ColumnNames Table Name ColumnName
CUSTOMER_TRX_ID AR_RECEIVABLE_APPLICATIONS_ALL APPLIED_CUSTOMER_TRX_ID
TERM_ID RA_TERMS TERM_ID
CUSTOMER_TRX_ID RA_CUST_TRX_LINE_GL_DIST CUSTOMER_TRX_ID
AR_CASH_REC EIPTS_ALL
ColumnNames Table Name Column Name
CASH_RECEIPT_ID AR_RECEIVABLE_APPLICATIONS_ALL CASH_RECEIPT_ID
SET_OF_BOOKS_ID GL_SETS_OF_BOOKS SET_OF_BOOKS_ID
What is the Diff betweenAPPS Schema and other Schemas?
AppsschemacontainsonlySynonymswe can'tcreate tablesinappsschema,where asother schemas
31. containstables,&all the objects.Here onlywe will create the tablesandgivinggrantsoncreatedtables.
Almostall everytime we will connecttoappsschemaonly.
What is meantby CustomTop and what is the Purpose?
CustomTop isnothingbutCustomerTop,whichis createdforcustomeronly.we can have multiplecustom
topsbasedon clientrequirement.Itisusedto store developed&customizedcomponents.
Wheneveroracle corporations applyingpatchesitwill override onall the modulesexceptcustomtop.
That’s whywe will use customtop.
FND USER EXITS:-
FND SRWINIT setsyourprofile optionvalues,multiple organizationsandallows
Oracle ApplicationObjectLibraryuserexitstodetectthattheyhave beencalledbyan
Oracle Reportsprogram.
FND SRWEXIT ensuresthatall the memoryallocatedforAOLuserexitshave beenfreed
up properly.
FND FLEXIDVAL are usedto displayflex fieldinformationlikeprompt,value etc
FND FLEXSQL these userexitsallowyoutouse flex fieldsinyourreports
FND FORMAT_CURRENCY isusedto printcurrencyin variousformatsbyusingformula
column