Wednesday, December 29, 2010

R12 Banks Queries

R12 Banks Queries

SELECT aps.vendor_name "VERDOR NAME",
apss.vendor_site_code "VENDOR SITE CODE",
ieb.bank_name "BANK NAME",
iebb.bank_branch_name "BANK BRANCH NAME",
iebb.branch_number "BRANCH NUMBER",
ieba.BANK_ACCOUNT_NUM "BANK ACCOUNT NUMBER",
ieba.BANK_ACCOUNT_NAME "BANK ACCOUNT NAME"
FROM ap.ap_suppliers aps,
ap.ap_supplier_sites_all apss,
apps.iby_ext_bank_accounts ieba,
apps.iby_account_owners iao,
apps.iby_ext_banks_v ieb,
apps.iby_ext_bank_branches_v iebb
WHERE aps.vendor_id = apss.vendor_id
and iao.account_owner_party_id = aps.party_id
and ieba.ext_bank_account_id = iao.ext_bank_account_id
and ieb.bank_party_id = iebb.bank_party_id
and ieba.branch_id = iebb.branch_party_id
and ieba.bank_id = ieb.bank_party_id;


SELECT party_supp.party_name supplier_name
, aps.segment1 supplier_number
, ass.vendor_site_code supplier_site
, ieb.bank_account_num
, ieb.bank_account_name
, party_bank.party_name bank_name
, branch_prof.bank_or_branch_number bank_number
, party_branch.party_name branch_name
, branch_prof.bank_or_branch_number branch_number
FROM hz_parties party_supp
, ap_suppliers aps
, hz_party_sites site_supp
, ap_supplier_sites_all ass
, iby_external_payees_all iep
, iby_pmt_instr_uses_all ipi
, iby_ext_bank_accounts ieb
, hz_parties party_bank
, hz_parties party_branch
, hz_organization_profiles bank_prof
, hz_organization_profiles branch_prof
WHERE party_supp.party_id = aps.party_id
AND party_supp.party_id = site_supp.party_id
AND site_supp.party_site_id = ass.party_site_id
AND ass.vendor_id = aps.vendor_id
AND iep.payee_party_id = party_supp.party_id
AND iep.party_site_id = site_supp.party_site_id
AND iep.supplier_site_id = ass.vendor_site_id
AND iep.ext_payee_id = ipi.ext_pmt_party_id
AND ipi.instrument_id = ieb.ext_bank_account_id
AND ieb.bank_id = party_bank.party_id
AND ieb.bank_id = party_branch.party_id
AND party_branch.party_id = branch_prof.party_id
AND party_bank.party_id = bank_prof.party_id
ORDER BY party_supp.party_name
, ass.vendor_site_code;

Delete Duplicate Records in Oracle

Delete Duplicate Records in Oracle

There are times when duplicate rows somehow creep into a table. The best scenario to happen this is when the data is to be imported from some other table or data and the Constraints are removed so that data import successfully. Removing duplicate rows from Oracle tables with SQL can be very tricky, and there are several techniques for identifying and removing duplicate rows from tables:

CREATE TABLE dup_test (
Emp_Id VARCHAR2(5),
Name VARCHAR2(15),
Phone NUMBER);

INSERT INTO dup_test values('100','John',473256);
INSERT INTO dup_test values('100','John',473256);
INSERT INTO dup_test values('101','Dave',561982);

SELECT * FROM dup_test;
Use subquery to delete duplicate rows:

Here we see an example of using SQL to delete duplicate table rows using an SQL subquery to identify duplicate rows, manually specifying the join columns:

DELETE FROM
dup_test A
WHERE
a.rowid >
ANY (
SELECT
B.rowid
FROM
dup_test B
WHERE
A.Emp_Id = B.Emp_Id
AND
A.Name = B.Name
AND
A.Phone = B.Phone
);
Use analytics to delete duplicate rows:

You can also detect and delete duplicate rows using Oracle analytic functions:

DELETE FROM dup_test
WHERE ROWID IN
(SELECT ROWID FROM (
SELECT ROW_NUMBER() OVER (PARTITION BY Emp_Id ORDER BY Emp_Id) rnk FROM dup_test)
WHERE rnk>1);
Use another table to delete duplicate rows:

This is the simplest method to remove duplicity.

CREATE TABLE dup_test_1 as select distinct * from dup_test;
DROP TABLE dup_test;
RENAME dup_test_1 to dup_test;
Use RANK to delete duplicate rows:

This is an example of the RANK function to identify and remove duplicate rows from Oracle tables, which deletes all duplicate rows while leaving the initial instance of the duplicate row:

DELETE FROM dup_test where rowid in
(
select "rowid" from
(select "rowid", rank_n from
(select rank() over (partition by Emp_Id order by rowid) rank_n, rowid as "rowid"
from dup_test
)
)
where rank_n > 1
);
The above methods are only standard methods. You can also use your own techniques to remove duplicate records.

Supplier Conversion in R12

Supplier Conversion in R12
Vendor conversion program will load the Supplier Master, Sites and Contacts data from data files to the staging tables, validate the data and then load the data into Interface tables, finally Validated data will import into Oracle Supplier Standard Tables by using Oracle Standard Supplier Import Programs.

Pre-requisites setup’s are: Payment terms, Pay Groups, CCID, Supplier classifications, Bank Accounts , Employees (if employees have to set up as vendors).

The Interface Tables are:

AP_SUPPLIERS_INT
AP_SUPPLIER_SITES_INT
AP_SUP_SITE_CONTACT_INT
AP_SUPPLIERS_INT:

This is the open interface table for AP Suppliers. It holds Supplier information which is loaded by the user for import. The columns in the table map to corresponding columns in the PO_VENDORS table. The Oracle Payables application uses this information to create a new Supplier record when the Supplier Open Interface Import program is submitted. Each row in the table will be identified by a unique identifier, the VENDOR_INTERFACE_ID.

Mandatory Columns:

VENDOR_INTERFACE_ID (ap_suppliers_int_s.NEXTVAL)- Supplier interface record unique identifier
VENDOR_NAME – Supplier name
Other important columns:

SEGMENT1 – Supplier Number
VENDOR_TYPE_LOOKUP_CODE – Supplier type
SHIP_TO_LOCATION_CODE – Default ship-to-location name
BILL_TO_LOCATION_CODE – Default bill-to-location name
TERMS_NAME – Payment terms name
TAX_VERIFICATION_DATE – Tax verification date(1099)
VAT_REGISTRATION_NUM – Tax registration number
ATTRIBUTE1 -15 – Descriptive Flexfield Segments
PAY_GROUP_LOOKUP_CODE – Payment group type
INVOICE_CURRENCY_CODE – Default currency unique identifier
PAYMENT_CURRENCY_CODE – Default payment currency unique identifier
NUM_1099 – Tax identification number (1099)
VAT_CODE – Default invoice tax code
HOLD_FLAG – Indicates whether or not the supplier is on purchasing hold
SUMMARY_FLAG – Key flexfield summary flag
ENABLED_FLAG – Key flexfield enable flag
EMPLOYEE_ID – Employee unique identifier if supplier is an employee
AP_SUPPLIER_SITES_INT:

This is the open interface table for AP Supplier Sites. It holds Supplier Site information which is loaded by the user for import. The columns in the table map to corresponding columns in PO_VENDOR_SITES_ALL table. The Oracle Payables application uses this information to create a new Supplier Site record when the Supplier Sites Open Interface Import program is submitted. Each row in the table will be joined to the appropriate Supplier using the VENDOR_ID column.

Mandatory Columns:

VENDOR_SITE_INTERFACE_ID (ap_supplier_sites_int_s.NEXTVAL) – Supplier Site interface record unique identifier
VENDOR_SITE_CODE – Supplier Site name
Other important columns:

ADDRESS_LINE1 – First line of supplier address
ADDRESS_LINE2 – Second line of supplier address
ADDRESS_LINE3 – Third line of supplier address
CITY – City name
STATE – State name or abbreviation
ZIP – Postal code
COUNTRY – Country name
PHONE – Phone number
FAX – Supplier site facsimile number
SHIP_TO_LOCATION_CODE – Default ship-to-location name
BILL_TO_LOCATION_CODE – Default bill-to-location name
PAYMENT_METHOD_LOOKUP_CODE – Default payment method type
VAT_CODE – Invoice default tax code
PAY_GROUP_LOOKUP_CODE – Payment group type
TERMS_NAME – Payment terms name
INVOICE_CURRENCY_CODE – Default currency unique identifier
PAYMENT_CURRENCY_CODE – Default payment currency unique identifier
EMAIL_ADDRESS – E-mail address of the supplier contact
PURCHASING_SITE_FLAG – Indicates whether purchasing is allowed from this site
AUTO_TAX_CALC_FLAG – Level of automatic tax calculation for supplier
HOLD_ALL_PAYMENTS_FLAG – Indicates if Oracle Payables should place payments for this supplier on hold
AP_SUP_SITE_CONTACT_INT:

This is the open interface table for AP Supplier Site Contacts. It holds Supplier contact data. The columns in the table map to corresponding columns in PO_VENDOR_CONTACTS table. The Oracle Payables application uses this information to create a new Supplier Contact record when the Supplier Sites Open Interface Import program is submitted. Each row in the table will be joined to the appropriate Supplier Site using the VENDOR_SITE_CODE and ORG_ID.

Mandatory Columns:

VENDOR_INTERFACE_ID – Supplier interface record unique identifier
VENDOR_CONTACT_INTERFACE_ID (AP_SUP_SITE_CONTACT_INT_S.NEXTVAL) – Vendor Contact Interface Identifier
VENDOR_SITE_CODE – Supplier Site name
Other important columns:

FIRST_NAME – Contact First name
LAST_NAME – Contact last name
AREA_CODE – Area code of contact phone number
PHONE – Contact phone number
FIRST_NAME_ALT – Alternate Supplier contact first name
LAST_NAME_ALT – Alternate Supplier contact last name
EMAIL_ADDRESS – Email address for the Supplier Site contact
FAX – Facsimile number for the Supplier Site contact
VENDOR_ID – Supplier unique identifier
Validations:

Vendor Number (Check for duplicate records in ap_suppliers table)
Vendor Name (Check for duplicate records in staging as well as in ap_suppliers table)
Terms Name (Check for proper record in ap_terms_tl table)
Pay Group (Check for proper record in fnd_lookup_values_vl table where lookup_type = ‘PAY GROUP’)
Employee Id (Check for proper employee record in per_all_people_f table)
Vendor Type (Check for proper record in po_lookup_codes table where lookup_type = ‘VENDOR TYPE’)
Vendor Site Code (Check for duplicate records in ap_supplier_sites_all table)
Country Code ( Check for proper country code in fnd_territories_vl table)
Payment Method (Check for proper payment method in iby_payment_methods_vl table)
Interface programs:

Supplier Open Interface Import
Supplier Sites Open Interface Import
Supplier Site Contacts Open Interface Import
The data inserted via these interfaces are automatically populated into TCA tables.

Note: AP_SUPPLIER_INT_REJECTIONS table contains suppliers, sites, contacts rejections information.

Thursday, December 16, 2010

Oracle R12 Banks Accounts Query

Oracle R12 Bank Accounts Query

SELECT owners.account_owner_party_id, asp.segment1 vendor_num,
asp.vendor_name,
(SELECT NAME
FROM hr_all_organization_units
WHERE TYPE = 'OU' AND organization_id = asa.org_id) ou_name,
asa.vendor_site_code, ieb.country_code
--, (select bank_name from ce_banks_v cbv where bank_party_id =ieb.bank_id) bank_name
--, (select bank_number from ce_banks_v cbv where bank_party_id =ieb.bank_id) bank_number
--, ieb.branch_id
, cbbv.bank_name, cbbv.bank_number, cbbv.bank_branch_name,
cbbv.branch_number, cbbv.bank_branch_type, cbbv.eft_swift_code,
ieb.bank_account_num, ieb.currency_code, ieb.iban,
ieb.foreign_payment_use_flag,
ieb.bank_account_name_alt bankacct_fromdata
FROM iby_pmt_instr_uses_all instrument,
iby_account_owners owners,
iby_external_payees_all payees,
iby_ext_bank_accounts ieb,
ap_supplier_sites_all asa,
ap_suppliers asp,
ce_bank_branches_v cbbv
WHERE owners.primary_flag = 'Y'
AND owners.ext_bank_account_id = ieb.ext_bank_account_id
AND owners.ext_bank_account_id = instrument.instrument_id
AND payees.ext_payee_id = instrument.ext_pmt_party_id
AND payees.payee_party_id = owners.account_owner_party_id
AND payees.supplier_site_id = asa.vendor_site_id
AND asa.vendor_id = asp.vendor_id
AND cbbv.branch_party_id(+) = ieb.branch_id
--and asa.org_id in (125)
AND asp.created_by = 1451
ORDER BY 4, 1, 3

Tuesday, November 30, 2010

Debugging Concurrent Programs

Concurrent Programs

For concurrent programs you can place in Log file / output file / fnd_log_messages table


For Log File
FND_FILE.PUT_LINE(FND_FILE.LOG,'your log statement');


For Output File
FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'your output statement');


For Tracing it in a table FND_LOG_MESSAGES


fnd_log.string(log_level => fnd_log.level_statement
,module => 'custom module'
,message => 'you log message here');

Workflow Mailer Debugging Script for Debugging Emails issues and event subscriptions

Workflow Mailer Debugging Script for Debugging Emails issues and event subscriptions
This article containts various Workflow and Business Event debugging scripts.


--Checking workflow Components status wheather are they running or stopped.
select component_type, component_name, Component_status,COMPONENT_STATUS_INFO Error
from fnd_svc_components
where component_type like 'WF%'
order by 1 desc,2,3;


--Query to get the log file of active workflow mailer and workflow agent listener Container
--Note All Workflow Agent Components logs will stored in single file ie. container log file.
select fl.meaning,fcp.process_status_code, decode(fcq.concurrent_queue_name,'WFMLRSVC', 'mailer container',
'WFALSNRSVC','listener container',fcq.concurrent_queue_name),
fcp.concurrent_process_id,os_process_id, fcp.logfile_name
from fnd_concurrent_queues fcq, fnd_concurrent_processes fcp , fnd_lookups fl
where fcq.concurrent_queue_id=fcp.concurrent_queue_id and fcp.process_status_code='A'
and fl.lookup_type='CP_PROCESS_STATUS_CODE' and fl.lookup_code=fcp.process_status_code
and concurrent_queue_name in('WFMLRSVC','WFALSNRSVC')
order by fcp.logfile_name;



--Linux Shell script Command to get outbound error in Mailer
grep -i '^\[[A-Za-z].*\(in\|out\).*boundThreadGroup.*\(UNEXPECTED\|ERROR\).*exception.*' | tail -10 ;
--Note: All Mailer log files starts with name FNDCPGSC prefix

--Linux Shell script Command to get inbound processing error in Mailer
grep -i '^\[[A-Za-z].*.*inboundThreadGroup.*\(UNEXPECTED\|ERROR\).*exception.*' | tail -10 ;


---Query to Check Workflow Mailer Backlog
--State=Ready implies that emails are not being sent & Waiting mailer to sent emails
select tab.msg_state, count(*) from applsys.aq$wf_notification_out tab group by tab.msg_state ;


--Check any particular Alert Message email has be pending by Mailer
select decode(wno.state,
0, '0 = Pending in mailer queue',
1, '1 = Pending in mailer queue',
2, '2 = Sent by mailer on '||to_char(DEQ_TIME),
3, '3 = Exception', 4,'4 = Wait', to_char(state)) State,
to_char(DEQ_TIME),
wno.user_data.TEXT_VC
from wf_notification_out wno
where corrid='APPS:ALR'
and upper(wno.user_data.TEXT_VC) like '%%';


--Check The Workflow notification has ben sent or not
select mail_status, status from wf_notifications where notification_id=
--If mail_status is MAIL , it means the email delivery is pending for workflow mailer to send the notification
--If mail_status is SENT, its means mailer has sent email
--If mail_status is Null & status is OPEN, its means that no need to send email as notification preference of user is "Don't send email"
--Notification preference of user can be set by user by loggin in application + click on preference + the notification preference


--Check Wheather workflow background Engine is workfing for given workflow or not in last 2 days
-- Note: Workflow Deferred activities are run by workflow background engine.
select a.argument1,a.phase_code, a.status_code ,a.actual_start_date,a.* from fnd_concurrent_requests a
where CONCURRENT_PROGRAM_ID =
(select concurrent_program_id from fnd_concurrent_programs where
CONCURRENT_PROGRAM_NAME='FNDWFBG')
and last_update_Date>sysdate-2 and argument1=''
order by last_update_date desc

-- Check wheather any business event is pending to process
-- ie. Query to get event status & parameters value of particular event in wf_deferred table.
select wd.user_Data.event_name,wd.user_Data.event_key,
rank() over ( partition by wd.user_Data.event_name, wd.user_Data.event_key order by n.name) as serial_no,
n.NAME Parameter_name, N.value Parameter_value ,
decode(state, 0, '0 = Ready', 1, '1 = Delayed', 2, '2 = Retained',
3, '3 = Exception', 4,'4 = Wait', to_char(state)) state,
wd.user_Data.SEND_DATE,
wd.user_Data.ERROR_MESSAGE,
wd.user_Data.ERROR_STACK,
wd.msgid,wd.delay
from WF_DEFERRED wd , TABLE(wd.user_Data.PARAMETER_LIST) n
where lower(wd.user_data.event_name)=''
order by wd.user_Data.event_name, wd.user_Data.event_key, n.name

Debugging OA pages

Debugging OA pages


a. Enable the profile option : FND: Debug Log Enabled -- Set to Yes
b. Enable the profile option : FND: Debug Log Level -- Set to Statement level
c. Add the below piece of code in your OA page
boolean isLoggingEnabled = pageContext.isLoggingEnabled(OAFwkConstants.STATEMENT);
if (isLoggingEnabled)
{
pageContext.writeDiagnostics(this, "your log statement", OAFwkConstants.STATEMENT);
}
To see log stmt on browser append below string to browser url and click on enter


&aflog_level=statement

Friday, November 12, 2010

R12 Suppliers Query

SELECT DISTINCT asp.vendor_id ,
asp.segment1 "Supplier Num" ,
ASp.vendor_name "Supplier Name" ,
ASP.ATTRIBUTE15 "HDRS LEGACY SUPP NO" ,
ass.vendor_site_code "SITE NAME" ,
hou.NAME "Operating Unit Name" ,
ass.address_line1 ,
ass.city ,
ass.state ,
ass.zip ,
ass.country ,
ass.phone ,
ASS.ATTRIBUTE15 "SITES LEGACY SUPP NO" ,
person.person_first_name ,
person.person_last_name ,
pty_rel.primary_phone_number ,
pty_rel.EMAIL_ADDRESS
FROM ap_suppliers asp ,
ap_supplier_sites_all ass ,
ap_supplier_contacts apsc ,
hz_parties person ,
hz_parties pty_rel,
hr_operating_units hou
WHERE 1 = 1
--AND ASP.VENDOR_NAME = PERSON.PARTY_NAME
AND ass.vendor_id = asp.vendor_id
AND apsc.per_party_id = person.party_id
AND apsc.rel_party_id = pty_rel.party_id
AND ass.org_id = hou.organization_id
AND apsc.ORG_PARTY_SITE_ID = ASS.PARTY_SITE_ID
AND ASP.ATTRIBUTE15 IN ('1240')
ORDER BY hou.NAME

Monday, October 25, 2010

HRMS Technical Site

Below site has HRMS Technical related stuff

http://wenku.baidu.com/view/d0a1d13383c4bb4cf7ecd10a.html

Monday, October 18, 2010

R12 Supplier Banks

In order to load Supplier external bank, branches and bank accounts, one needs to use the Oracle Supplied Package IBY_EXT_BANKACCT_PUB.

Below API's are used to create Bank and Branch

IBY_EXT_BANKACCT_PUB.create_ext_bank:

It is used to create the External Bank, please note that the Bank name and Home Country Name are mandatory for creating an External Bank. Once you create the Bank, Bank Party ID gets created and you can check it from IBY_EXT_BANKS_V view.

IBY_EXT_BANKACCT_PUB.create_ext_bank
(p_api_version => 1.0
,p_init_msg_list => FND_API.G_TRUE
,p_ext_bank_rec => x_bank_rec
,x_bank_id => x_bank_id
,x_return_status => x_return_status
,x_msg_count => x_msg_count
,x_msg_data => x_msg_data
,x_response => x_response_rec
);

IBY_EXT_BANKACCT_PUB.create_ext_bank_branch

It is used to create a Bank Branch, so that an account could be created in the same branch. Once a Bank Branch is created, a record gets inserted into IBY_EXT_BANK_BRANCHES_V view.

IBY_EXT_BANKACCT_PUB.create_ext_bank_branch
(p_api_version => 1.0
,p_init_msg_list => FND_API.G_TRUE
,p_ext_bank_branch_rec => x_bank_branch_rec
,x_branch_id => x_branch_id
,x_return_status => x_return_status
,x_msg_count => x_msg_count
,x_msg_data => x_msg_data
,x_response => x_response_rec
);

After the bank and branches are created, the table iby.iby_temp_ext_bank_accounts can be populated to create the bank accounts and associate to the supplier or supplier site

Note: Table must be populated prior to running the supplier interface

Below API's are used internally by oracle to create payee and associate bank account to supplier or supplier site.

IBY_EXT_BANKACCT_PUB.create_ext_bank_acct
(p_api_version => 1.0
,p_init_msg_list => FND_API.G_TRUE
,p_ext_bank_acct_rec => x_bank_acct_rec
,x_acct_id => x_acct_id
,x_return_status => x_return_status
,x_msg_count => x_msg_count
,x_msg_data => x_msg_data
,x_response => x_response_rec
);

IBY_DISBURSEMENT_SETUP_PUB.Create_External_Payee
(p_api_version => 1.0,
p_init_msg_list => FND_API.G_TRUE,
p_ext_payee_tab => v_external_payee_tab_type,
x_return_status => v_return_status,
x_msg_count => v_msg_count,
x_msg_data => v_msg_data,
x_ext_payee_id_tab => x_ext_payee_id_tab,
x_ext_payee_status_tab => x_ext_payee_status_tab);

IBY_DISBURSEMENT_SETUP_PUB.Set_Payee_Instr_Assignment
(p_api_version => 1.0
,p_init_msg_list => FND_API.G_TRUE
,p_payee => x_rec
,p_assignment_attribs => x_assign
,x_assign_id => x_assign_id
,x_return_status => x_return_status
,x_msg_count => x_msg_count
,x_msg_data => x_msg_data
,x_response => x_response_rec);

From Amit Chintawar

Monday, October 4, 2010

R12 Supplier Payment Method Table/View

IBY_EXTERNAL_PAYEES_ALL : This stores supplier information and customer information
IBY_EXT_BANK_ACCOUNTS : This storage for bank accounts
IBY_EXT_PARTY_PMT_MTHDS : This storage for payment method usage rules.
IBY_CREDITCARD : stores the credit card information for a customer
IBY_EXT_BANK_ACCOUNTS :This Stores external bank accounts . These records have bank_account_type = Supplier
IBY_ACCOUNT_OWNERS :stores the joint account owners of a bank account
IBY_PMT_INSTR_USES_ALL : This stores data from AP_BANK_ACCOUNT_USES_ALL for payment instruments assignments .This information is stored in the following iPayment (IBY) tables:

Wednesday, September 22, 2010

New MetaLink eTRM Path

Knowledge (tab) --> Online Documentation (left side bottom) --> E-Business Suite Documentation --> Electronic Technical Reference Manual (eTRM)

Tuesday, August 31, 2010

How to execute VIEWS (AP_INVOICE_V) and see data in toad for R12.

How to execute VIEWS (AP_INVOICE_V) and see data in toad for R12.

begin
MO_GLOBAL.SET_ORG_CONTEXT('125',NULL,'SQLAP');
end;

commit

125--- Operating Unit

Thursday, August 26, 2010

CUSTOM FORM DEVELOPMENT

On the CLIENT machine create a FOLDER as say: c:\custom_test

In custom_test folder creates 2 folders forms, resource

Copy TEMPLATE.fmb, APPSTAND.fmb, .pll files to CLIENT

• Copy TEMPLATE.fmb , APPSTAND.fmb from AU_TOP/forms/US to c:\custom_test\ forms directory copy all .pll files from /Applvis/visappl/au/11.5.0/resource to c:\custom_test\resource using ftp
• On windows go to command prompt
• Cd c:\custom_test\forms
• ftp cloneserver
• username: applmgr password: applmgr
• now you are at ftp prompt
• bin
• prompt
• cd visappl/au/11.5.0/forms/US ( here apparently cd $AU_TOP does not work)
• get TEMPLATE.fmb
• (file copied)
• get APPSTAND.fmb
• (file copied)
• lcd ./resource (check this. Basically you need to be in c:\custom_test\resource. You can go to that directory and then run ftp)
• cd visappl/au/11.5.0/resource
• mget *.pll
• ( now all .pll files are copied to c:custom_test/resource)

SET env variable FORMS60_PATH through regedit

• Regedit/HKEY_LOCAL_MACHINE/software/oracle
• Double click FORMS60_PATH
• At the end of existing value data add: ;c:\custom_test\froms;c:\custom_test\resource

Now open TEMPLATE.fmb and make the following changes

• DELETE BLOCKNAME &DETAIL BLOCK FROM DATABLOCK,DELETE BLOCKNAME FROM CANVAS AND WINDOW
• Create a window NEW_WIN, canvas NEW_CAN
• Create a new block based on the table you created in your custom schema
• In pre-form trigger: app_windows.set_window_position(‘NEW_WIN’)…….
• In program units open custom_package.AP_cutom_pacakge body
• Change : if (wind=’NEW_WIN’);
• Template name = TEST_FORM
• Save as TEST_FROM to c:\custom_test\forms
• (????????SET THE WINDOW NAME AS U HAVE CREATED NEW WINDOW IN PRE-FORM TRIGGER BY BLOCKNAME?????)

DEPLOY the FORM (upload it to AU_TOP/forms/US)

• Go to command prompt (on client)
• cd c:\cutom_test\forms
• ftp cloneserver
• cd visappl/au/11.5.0/froms/US
• bin
• prompt
• put TEST_FORM.fmb


Changing ORACLE_HOME (/Visdb/visdb/9.2.0 to /Applvis/visora/8.0.6)

• thru putty login as applmgr
• pwd: /Applvis
• echo $ORACLE_HOME: shows /Visdb/visdb/9.2.0
• cd visora
• cd 8.0.6
• . VIS_cloneserver.env (this changes ORACLE_HOME apparently based on pwd?)
• echo $ORACLE_HOME: shows /Applvis/visora/8.0.6
• now ORACLE_HOME is 8.0.6 (forms/reports home)
• pwd : gives /Applvis/visora/8.0.6

COMPILE and generate FMX

• (now you are in /Applvis/visora/8.0.6 directory and ORACLE_HOME is set to /Applvis/visora/8.0.6)
• pwd: gives /Applvis/visora/8.0.6
• f60gen module=$AU_TOP/forms/US/TEST_FORMS.fmb module_type=form user=apps output_file=$TEST_TOP/forms/US/TEST_FORM.fmx compile_all=special batch=no
• this generates TEST_FORM.fmx and puts in TEST_TOP/forms/US

FORM REGISTRATION

• Login to applications with application developer responsibility
• Application/form
• Enter the following details
o Form: the fmx name (TEST_FORM)
o Application: Oracle Receivables (as per Amer) –give appropriate name based the intended use of this form
o user form name: TEST_FORM_U (this will appear in LOV)
o SAVE

Attach the FORM to FUNCTION
(Create a new function)
Application/function
Enter the following details
o Function: TEST_FUNCT
o User function name: TEST FUNCTION
o Form: TEST_FORM (previously registered)
o SAVE

Attach FUNCTION to MENU
Application/menu
• Enter the following details
o Menu: test_menu
o User menu name: test menu
o Seq: 1
o Prompt: test form
o Function: TEST_FUNCT( previously deined)
o SAVE

Attach MENU to RESPONSIBILITY

Attach RESPONSIBILITY to USER

Login as the new USER

SQL Interview Questions

1. The most important DDL statements in SQL are:
CREATE TABLE - creates a new database table
ALTER TABLE - alters (changes) a database table
DROP TABLE - deletes a database table
TRUNCATE - cleans all data
RENAME- renames a table name

2. Operators used in SELECT statements.
= Equal
<> or != Not equal
> Greater than
<>= Greater than or equal
<= Less than or equal BETWEEN Between an inclusive range LIKE Search for a pattern

3. SELECT statements:
SELECT column_name(s) FROM table_name
SELECT DISTINCT column_name(s) FROM table_name
SELECT column FROM table WHERE column operator value
SELECT column FROM table WHERE column LIKE pattern
SELECT column,SUM(column) FROM table GROUP BY column
SELECT column,SUM(column) FROM table GROUP BY column HAVING SUM(column) condition value
Note that single quotes around text values and numeric values should not be enclosed in quotes. Double quotes may be acceptable in some databases.

4. The SELECT INTO Statement is most often used to create backup copies of tables or for archiving records.
SELECT column_name(s) INTO newtable [IN externaldatabase] FROM source
SELECT column_name(s) INTO newtable [IN externaldatabase] FROM source WHERE column_name operator value

5. The INSERT INTO Statements:
INSERT INTO table_name VALUES (value1, value2,....)
INSERT INTO table_name (column1, column2,...) VALUES (value1, value2,....)

6. The Update Statement:
UPDATE table_name SET column_name = new_value WHERE column_name = some_value

7. The Delete Statements:
DELETE FROM table_name WHERE column_name = some_value
Delete All Rows:
DELETE FROM table_name or DELETE * FROM table_name

8. Sort the Rows:
SELECT column1, column2, ... FROM table_name ORDER BY columnX, columnY, ..
SELECT column1, column2, ... FROM table_name ORDER BY columnX DESC
SELECT column1, column2, ... FROM table_name ORDER BY columnX DESC, columnY ASC

9. The IN operator may be used if you know the exact value you want to return for at least one of the columns.
SELECT column_name FROM table_name WHERE column_name IN (value1,value2,..)

10. BETWEEN ... AND
SELECT column_name FROM table_name WHERE column_name BETWEEN value1 AND value2 The values can be numbers, text, or dates.

11. What is the use of CASCADE CONSTRAINTS?
When this clause is used with the DROP command, a parent table can be dropped even when a child table exists.

12. Why does the following command give a compilation error?
DROP TABLE &TABLE NAME; Variable names should start with an alphabet. Here the table name starts with an '&' symbol.

13. Which system tables contain information on privileges granted and privileges obtained? USER_TAB_PRIVS_MADE, USER_TAB_PRIVS_RECD

14. Which system table contains information on constraints on all the tables created?obtained? USER_CONSTRAINTS.

15. State true or false. !=, <>, ^= all denote the same operation?
True.

16. State true or false. EXISTS, SOME, ANY are operators in SQL?
True.

17. What will be the output of the following query?
SELECT REPLACE(TRANSLATE(LTRIM(RTRIM('!! ATHEN !!','!'), '!'), 'AN', '**'),'*','TROUBLE') FROM DUAL;?

18. What does the following query do?
SELECT SAL + NVL(COMM,0) FROM EMP;?
This displays the total salary of all employees. The null values in the commission column will be replaced by 0 and added to salary.

19. What is the advantage of specifying WITH GRANT OPTION in the GRANT command?
The privilege receiver can further grant the privileges he/she has obtained from the owner to any other user.

20. Which command executes the contents of a specified file?
START or @.

21. What is the value of comm and sal after executing the following query if the initial value of ‘sal’ is 10000
UPDATE EMP SET SAL = SAL + 1000, COMM = SAL*0.1;?
sal = 11000, comm = 1000.

22. Which command displays the SQL command in the SQL buffer, and then executes it?
RUN.

23. What command is used to get back the privileges offered by the GRANT command?
REVOKE.

24. What will be the output of the following query? SELECT DECODE(TRANSLATE('A','1234567890','1111111111'), '1','YES', 'NO' );? NO.
Explanation : The query checks whether a given string is a numerical digit.

26. Which date function is used to find the difference between two dates?
MONTHS_BETWEEN.

27. What operator performs pattern matching?
LIKE operator.

28. What is the use of the DROP option in the ALTER TABLE command?
It is used to drop constraints specified on the table.

29. What operator tests column for the absence of data?
IS NULL operator.

30. What are the privileges that can be granted on a table by a user to others?
Insert, update, delete, select, references, index, execute, alter, all.

31. Which function is used to find the largest integer less than or equal to a specific value?
FLOOR.

32. Which is the subset of SQL commands used to manipulate Oracle Database structures, including tables?
Data Definition Language (DDL).

33. What is the use of DESC in SQL?
DESC has two purposes. It is used to describe a schema as well as to retrieve rows from table in descending order.
Explanation :
The query SELECT * FROM EMP ORDER BY ENAME DESC will display the output sorted on ENAME in descending order.

34. What command is used to create a table by copying the structure of another table?
CREATE TABLE .. AS SELECT command
Explanation:
To copy only the structure, the WHERE clause of the SELECT command should contain a FALSE statement as in the following.
CREATE TABLE NEWTABLE AS SELECT * FROM EXISTINGTABLE WHERE 1=2;
If the WHERE condition is true, then all the rows or rows satisfying the condition will be copied to the new table.

35. TRUNCATE TABLE EMP;DELETE FROM EMP;
Will the outputs of the above two commands differ?
Both will result in deleting all the rows in the table EMP..

36. What is the output of the following query SELECT TRUNC(1234.5678,-2) FROM DUAL;?
1200.

37. What are the wildcards used for pattern matching.?
_ for single character substitution and % for multi-character substitution.

38. What is the parameter substitution symbol used with INSERT INTO command?
&

39. What's an SQL injection?
SQL Injection is when form data contains an SQL escape sequence and injects a new SQL query to be run.

40. What is difference between TRUNCATE & DELETE
TRUNCATE commits after deleting entire table i.e., cannot be rolled back. Database triggers do not fire on TRUNCATE
DELETE allows the filtered deletion. Deleted records can be rolled back or committed. Database triggers fire on DELETE.

41. What is a join? Explain the different types of joins?
Join is a query, which retrieves related columns or rows from multiple tables.
Self Join - Joining the table with itself.
Equi Join - Joining two tables by equating two common columns.
Non-Equi Join - Joining two tables by equating two common columns.
Outer Join - Joining two tables in such a way that query can also retrieve rows that do not have corresponding join value in the other table.

42. What is the sub-query?
Sub-query is a query whose return values are used in filtering conditions of the main query.

43. What is correlated sub-query?
Correlated sub-query is a sub-query, which has reference to the main query.

44. Explain CONNECT BY PRIOR?
Retrieves rows in hierarchical order eg.
select empno, ename from emp where.

45. Difference between SUBSTR and INSTR?
INSTR (String1, String2 (n, (m)),
INSTR returns the position of the m-th occurrence of the string 2 in string1. The search begins from nth position of string1.
SUBSTR (String1 n, m)
SUBSTR returns a character string of size m in string1, starting from n-th position of string1.

46. Explain UNION, MINUS, UNION ALL and INTERSECT?
INTERSECT - returns all distinct rows selected by both queries.
MINUS - returns all distinct rows selected by the first query but not by the second.
UNION - returns all distinct rows selected by either query
UNION ALL - returns all rows selected by either query, including all duplicates.

47. What is ROWID?
ROWID is a pseudo column attached to each row of a table. It is 18 characters long, blockno, rownumber are the components of ROWID.

48. What is the fastest way of accessing a row in a table?
Using ROWID.
CONSTRAINTS

49. What is an integrity constraint?
Integrity constraint is a rule that restricts values to a column in a table.

50. What is referential integrity constraint?
Maintaining data integrity through a set of rules that restrict the values of one or more columns of the tables based on the values of primary key or unique key of the referenced table.

51. What is the usage of SAVEPOINTS?
SAVEPOINTS are used to subdivide a transaction into smaller parts. It enables rolling back part of a transaction. Maximum of five save points are allowed.

52. What is ON DELETE CASCADE?
When ON DELETE CASCADE is specified Oracle maintains referential integrity by automatically removing dependent foreign key values if a referenced primary or unique key value is removed.

53. What are the data types allowed in a table?
CHAR, VARCHAR2, NUMBER, DATE, RAW, LONG and LONG RAW.

54. What is difference between CHAR and VARCHAR2? What is the maximum SIZE allowed for each type?
CHAR pads blank spaces to the maximum length.
VARCHAR2 does not pad blank spaces.
For CHAR the maximum length is 255 and 2000 for VARCHAR2.

55. 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.

56. What are the pre-requisites to modify datatype of a column and to add a column 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.

57. Where the integrity constraints are stored in data dictionary?
The integrity constraints are stored in USER_CONSTRAINTS.

58. How will you activate/deactivate integrity constraints?
The integrity constraints can be enabled or disabled by ALTER TABLE ENABLE CONSTRAINT / DISABLE CONSTRAINT.

59. If unique key constraint on DATE column is created, will it validate the rows that are inserted with SYSDATE?
It won't, Because SYSDATE format contains time attached with it.

60. What is a database link?
Database link is a named path through which a remote database can be accessed.

61. How to access the current value and next value from a sequence? Is it possible to access the current value in a session before accessing next value?
Sequence name CURRVAL, sequence name NEXTVAL. It is not possible. Only if you access next value in the session, current value can be accessed.

62.What is CYCLE/NO CYCLE in a Sequence?
CYCLE specifies that the sequence continue to generate values after reaching either maximum or minimum value. After pan-ascending sequence reaches its maximum value, it generates its minimum value. After a descending sequence reaches its minimum, it generates its maximum.
NO CYCLE specifies that the sequence cannot generate more values after reaching its maximum or minimum value.

63. What are the advantages of VIEW?
- To protect some of the columns of a table from other users.
- To hide complexity of a query.
- To hide complexity of calculations.

64. Can a view be updated/inserted/deleted? If Yes - under what conditions?
A View can be updated/deleted/inserted if it has only one base table if the view is based on columns from one or more tables then insert, update and delete is not possible.

65. If a view on a single base table is manipulated will the changes be reflected on the base table?
If changes are made to the tables and these tables are the base tables of a view, then the changes will be reference on the view.

66. Which of the following statements is true about implicit cursors?
1. Implicit cursors are used for SQL statements that are not named.
2. Developers should use implicit cursors with great care.
3. Implicit cursors are used in cursor for loops to handle data processing.
4. Implicit cursors are no longer a feature in Oracle.

67. Which of the following is not a feature of a cursor FOR loop?
1. Record type declaration.
2. Opening and parsing of SQL statements.
3. Fetches records from cursor.
4. Requires exit condition to be defined.

66. A developer would like to use referential datatype declaration on a variable. The variable name is EMPLOYEE_LASTNAME, and the corresponding table and column is EMPLOYEE, and LNAME, respectively. How would the developer define this variable using referential datatypes?
1. Use employee.lname%type.
2. Use employee.lname%rowtype.
3. Look up datatype for EMPLOYEE column on LASTNAME table and use that.
4. Declare it to be type LONG.

67. Which three of the following are implicit cursor attributes?
1. %found
2. %too_many_rows
3. %notfound
4. %rowcount
5. %rowtype

68. If left out, which of the following would cause an infinite loop to occur in a simple loop?
1. LOOP
2. END LOOP
3. IF-THEN
4. EXIT

69. Which line in the following statement will produce an error?
1. cursor action_cursor is
2. select name, rate, action
3. into action_record
4. from action_table;
5. There are no errors in this statement.

70. The command used to open a CURSOR FOR loop is
1. open
2. fetch
3. parse
4. None, cursor for loops handle cursor opening implicitly.

71. What happens when rows are found using a FETCH statement
1. It causes the cursor to close
2. It causes the cursor to open
3. It loads the current row values into variables
4. It creates the variables to hold the current row values

72. Read the following code:
10. CREATE OR REPLACE PROCEDURE find_cpt
11. (v_movie_id {Argument Mode} NUMBER, v_cost_per_ticket {argument mode} NUMBER)
12. IS
13. BEGIN
14. IF v_cost_per_ticket > 8.5 THEN
15. SELECT cost_per_ticket
16. INTO v_cost_per_ticket
17. FROM gross_receipt
18. WHERE movie_id = v_movie_id;
19. END IF;
20. END;
Which mode should be used for V_COST_PER_TICKET?
1. IN
2. OUT
3. RETURN
4. IN OUT
73. Read the following code:
22. CREATE OR REPLACE TRIGGER update_show_gross
23. {trigger information}
24. BEGIN
25. {additional code}
26. END;
The trigger code should only execute when the column, COST_PER_TICKET, is greater than $3. Which trigger information will you add?
1. WHEN (new.cost_per_ticket > 3.75)
2. WHEN (:new.cost_per_ticket > 3.75
3. WHERE (new.cost_per_ticket > 3.75)
4. WHERE (:new.cost_per_ticket > 3.75)

74. What is the maximum number of handlers processed before the PL/SQL block is exited when an exception occurs?
1. Only one
2. All that apply
3. All referenced
4. None

77. For which trigger timing can you reference the NEW and OLD qualifiers?
1. Statement and Row 2. Statement only 3. Row only 4. Oracle Forms trigger

78. Read the following code:
CREATE OR REPLACE FUNCTION get_budget(v_studio_id IN NUMBER)
RETURN number IS
v_yearly_budget NUMBER;
BEGIN
SELECT yearly_budget
INTO v_yearly_budget
FROM studio
WHERE id = v_studio_id;
RETURN v_yearly_budget;
END;
Which set of statements will successfully invoke this function within SQL*Plus?
1. VARIABLE g_yearly_budget NUMBER
EXECUTE g_yearly_budget := GET_BUDGET(11);
2. VARIABLE g_yearly_budget NUMBER
EXECUTE :g_yearly_budget := GET_BUDGET(11);
3. VARIABLE :g_yearly_budget NUMBER
EXECUTE :g_yearly_budget := GET_BUDGET(11);
4. VARIABLE g_yearly_budget NUMBER
31. CREATE OR REPLACE PROCEDURE update_theater
32. (v_name IN VARCHAR v_theater_id IN NUMBER) IS
33. BEGIN
34. UPDATE theater
35. SET name = v_name
36. WHERE id = v_theater_id;
37. END update_theater;

79. When invoking this procedure, you encounter the error:
ORA-000:Unique constraint(SCOTT.THEATER_NAME_UK) violated.
How should you modify the function to handle this error?
1. An user defined exception must be declared and associated
with the error code and handled in the EXCEPTION section.
2. Handle the error in EXCEPTION section by referencing the error
code directly.
3. Handle the error in the EXCEPTION section by referencing the UNIQUE_ERROR predefined exception.
4. Check for success by checking the value of SQL%FOUND immediately after the UPDATE statement.

80. Read the following code:
40. CREATE OR REPLACE PROCEDURE calculate_budget IS
41. v_budget studio.yearly_budget%TYPE;
42. BEGIN
43. v_budget := get_budget(11);
44. IF v_budget < 30000
45. THEN
46. set_budget(11,30000000);
47. END IF;
48. END; You are about to add an argument to CALCULATE_BUDGET.
What effect will this have?
1. The GET_BUDGET function will be marked invalid and must be recompiled before the next execution.
2. The SET_BUDGET function will be marked invalid and must be recompiled before the next execution.
3. Only the CALCULATE_BUDGET procedure needs to be recompiled.
4. All three procedures are marked invalid and must be recompiled.

81. Which procedure can be used to create a customized error message?
1. RAISE_ERROR
2. SQLERRM
3. RAISE_APPLICATION_ERROR
4. RAISE_SERVER_ERROR

82. The CHECK_THEATER trigger of the THEATER table has been disabled. Which command can you issue to enable this trigger?
1. ALTER TRIGGER check_theater ENABLE;
2. ENABLE TRIGGER check_theater;
3. ALTER TABLE check_theater ENABLE check_theater;
4. ENABLE check_theater;

83. Examine this database trigger
52. CREATE OR REPLACE TRIGGER prevent_gross_modification
53. {additional trigger information}
54. BEGIN
55. IF TO_CHAR(sysdate, DY) = MON
56. THEN
57. RAISE_APPLICATION_ERROR(-20000,Gross receipts cannot be deleted on Monday);
58. END IF;
59. END;
This trigger must fire before each DELETE of the GROSS_RECEIPT table. It should fire only once for the entire DELETE statement. What additional information must you add?
1. BEFORE DELETE ON gross_receipt
2. AFTER DELETE ON gross_receipt
3. BEFORE (gross_receipt DELETE)
4. FOR EACH ROW DELETED FROM gross_receipt

84. Examine this function:
61. CREATE OR REPLACE FUNCTION set_budget
62. (v_studio_id IN NUMBER, v_new_budget IN NUMBER) IS
63. BEGIN
64. UPDATE studio
65. SET yearly_budget = v_new_budget WHERE id = v_studio_id; IF SQL%FOUND THEN RETURN TRUEl; ELSE RETURN FALSE; END IF; COMMIT; END; Which code must be added to successfully compile this function?
1. Add RETURN right before the IS keyword.
2. Add RETURN number right before the IS keyword.
3. Add RETURN boolean right after the IS keyword.
4. Add RETURN boolean right before the IS keyword.

85. Under which circumstance must you recompile the package body after recompiling the package specification?
1. Altering the argument list of one of the package constructs
2. Any change made to one of the package constructs
3. Any SQL statement change made to one of the package constructs
4. Removing a local variable from the DECLARE section of one of the package constructs

86. Procedure and Functions are explicitly executed. This is different from a database trigger. When is a database trigger executed?
1. When the transaction is committed
2. During the data manipulation statement
3. When an Oracle supplied package references the trigger
4. During a data manipulation statement and when the transaction is committed

87. Which Oracle supplied package can you use to output values and messages from database triggers, stored procedures and functions within SQL*Plus?
1. DBMS_DISPLAY
2. DBMS_OUTPUT
3. DBMS_LIST
4. DBMS_DESCRIBE

88. What occurs if a procedure or function terminates with failure without being handled?
1. Any DML statements issued by the construct are still pending and can be committed or rolled back.
2. Any DML statements issued by the construct are committed
3. Unless a GOTO statement is used to continue processing within the BEGIN section,the construct terminates.
4. The construct rolls back any DML statements issued and returns the unhandled exception to the calling environment.

89. Examine this code
71. BEGIN
72. theater_pck.v_total_seats_sold_overall := theater_pck.get_total_for_year;
73. END; For this code to be successful, what must be true?
1. Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR function must exist only in the body of the THEATER_PCK package.
2. Only the GET_TOTAL_FOR_YEAR variable must exist in the specification of the THEATER_PCK package.
3. Only the V_TOTAL_SEATS_SOLD_OVERALL variable must exist in the specification of the THEATER_PCK package.
4. Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR function must exist in the specification of the THEATER_PCK package.

90. A stored function must return a value based on conditions that are determined at runtime. Therefore, the SELECT statement cannot be hard-coded and must be created dynamically when the function is executed. Which Oracle supplied package will enable this feature?
1. DBMS_DDL
2. DBMS_DML
3. DBMS_SYN
4. DBMS_SQL

91 How to implement ISNUMERIC function in SQL *Plus ? Method
1: Select length (translate(trim (column_name),'+-.0123456789',''))from dual; Will give you a zero if it is a number or greater than zero if not numeric (actually gives the count of non numeric characters) Method 2: select instr(translate('wwww','abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ','XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXX'),'X') FROM dual; It returns 0 if it is a number, 1 if it is not.

92 How to Select last N records from a Table? select * from (select rownum a, CLASS_CODE,CLASS_DESC from clm) where a > ( select (max(rownum)-10) from clm) Here N = 10
The following query has a Problem of performance in the execution of the following
query where the table ter.ter_master have 22231 records. So the results are obtained
after hours.
Cursor rem_master(brepno VARCHAR2) IS
select a.* from ter.ter_master a
where NOT a.repno in (select repno from ermast) and
(brepno = 'ALL' or a.repno > brepno)
Order by a.repno
What are steps required tuning this query to improve its performance?
-Have an index on TER_MASTER.REPNO and one on ERMAST.REPNO
-Be sure to get familiar with EXPLAIN PLAN. This can help you determine the execution
path that Oracle takes. If you are using Cost Based Optimizer mode, then be sure that
your statistics on TER_MASTER are up-to-date. -Also, you can change your SQL to:
SELECT a.*
FROM ter.ter_master a
WHERE NOT EXISTS (SELECT b.repno FROM ermast b
WHERE a.repno=b.repno) AND
(a.brepno = 'ALL' or a.repno > a.brepno)
ORDER BY a.repno;

93. What is the difference between Truncate and Delete interms of Referential Integrity?
DELETE removes one or more records in a table, checking referential Constraints (to see if there are dependent child records) and firing any DELETE triggers. In the order you are deleting (child first then parent) There will be no problems.
TRUNCATE removes ALL records in a table. It does not execute any triggers. Also, it
only checks for the existence (and status) of another foreign key Pointing to the
table. If one exists and is enabled, then you will get The following error. This
is true even if you do the child tables first.
ORA-02266: unique/primary keys in table referenced by enabled foreign keys
You should disable the foreign key constraints in the child tables before issuing
the TRUNCATE command, then re-enable them afterwards.

PL-SQL Interview Questions

PL-SQL Interview Questions

1. Describe the difference between a procedure, function and anonymous pl/sql block.
Level: Low
Expected answer : Candidate should mention use of DECLARE statement, a function must
return a value while a procedure doesn?t have to.

2. What is a mutating table error and how can you get around it?
Level: Intermediate
Expected answer: 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 temporary tables so the database is selecting from one while updating the other.

3. Describe the use of %ROWTYPE and %TYPE in PL/SQL
Level: Low
Expected answer: %ROWTYPE allows you to associate a variable with an entire table row.
The %TYPE associates a variable with a single column type.

4. What packages (if any) has Oracle provided for use by developers?
Expected answer: Oracle provides the DBMS_ series of packages. There are many
which developers should be aware of such as DBMS_SQL, DBMS_PIPE, DBMS_TRANSACTION,
DBMS_LOCK, DBMS_ALERT, DBMS_OUTPUT, DBMS_JOB, DBMS_UTILITY, DBMS_DDL, UTL_FILE. If
they can mention a few of these and describe how they used them, even better. If
they include the SQL routines provided by Oracle, great, but not really what
was asked.

5. Describe the use of PL/SQL tables
Expected answer: PL/SQL tables are scalar arrays that can be referenced by a
binary integer. They can be used to hold values for use in later queries
or calculations. In Oracle 8 they will be able to be of the %ROWTYPE designation,
or RECORD.

6. When is a declare statement needed ?
The DECLARE statement is used in PL/SQL anonymous blocks such as with stand alone, non-stored PL/SQL procedures. It must come first in a PL/SQL stand alone file if it is used.

7. In what order should a open/fetch/loop set of commands in a PL/SQL block be implemented if you use the NOTFOUND cursor variable in the exit when statement? Why?
Expected answer: OPEN then FETCH then LOOP followed by the exit when. If not specified in this order will result in the final return being done twice because of the way the %NOTFOUND is handled by PL/SQL.

8. What are SQLCODE and SQLERRM and why are they important for PL/SQL developers?
Expected answer: SQLCODE returns the value of the error number for the last error encountered. The SQLERRM returns the actual error message for the last error encountered. They can be used in exception handling to report, or, store in an error log table, the error that occurred in the code. These are especially useful for the WHEN OTHERS exception.

9. How can you find within a PL/SQL block, if a cursor is open?
Expected answer: Use the %ISOPEN cursor status variable.

10. How can you generate debugging output from PL/SQL?
Expected answer: Use the DBMS_OUTPUT package. Another possible method is to just use the SHOW ERROR command, but this only shows errors. The DBMS_OUTPUT package can be used to show intermediate results from loops and the status of variables as the procedure is executed. The new package UTL_FILE can
also be used.

11. What are the types of triggers?
Expected Answer: There are 12 types of triggers in PL/SQL that consist of
combinations of the BEFORE, AFTER, ROW, TABLE, INSERT, UPDATE, DELETE and
ALL key words:
BEFORE ALL ROW INSERT
AFTER ALL ROW INSERT
BEFORE INSERT
AFTER INSERT etc.

SQL / SQLPlus Interview Questions

SQL / SQLPlus Interview Questions

1. How can variables be passed to a SQL routine?
Expected answer: By use of the & symbol. For passing in variables the numbers
1-8 can be used (&1, &2,...,&8) to pass the values after the command into the
SQLPLUS session. To be prompted for a specific variable, place the ampersanded
variable in the code itself:
"select * from dba_tables where owner=&owner_name;" . Use of double
ampersands tells SQLPLUS to resubstitute the value for each subsequent
use of the variable, a single ampersand will cause a reprompt for the
value unless an ACCEPT statement is used to get the value from the user.

2. You want to include a carriage return/linefeed in your output from a SQL script, how can you do this?
Expected answer: The best method is to use the CHR() function (CHR(10) is a return/linefeed) and the concatenation function "". Another method, although it is hard to document and isn?t always portable is to use the return/linefeed as a part of a quoted string.

3. How can you call a PL/SQL procedure from SQL?
Expected answer: By use of the EXECUTE (short form EXEC) command.

4. How do you execute a host operating system command from within SQL?
Expected answer: By use of the exclamation point "!" (in UNIX and some other OS) or the HOST (HO) command.

5. You want to use SQL to build SQL, what is this called and give an example
Expected answer: This is called dynamic SQL. An example would be:
set lines 90 pages 0 termout off feedback off verify off
spool drop_all.sql
select ?drop user ?username? cascade;? from dba_users
where username not in ("SYS?,?SYSTEM?);
spool off
Essentially you are looking to see that they know to include a command (in this case DROP USER...CASCADE;) and that you need to concatenate using the ?? the values selected from the database.

6. What SQLPlus command is used to format output from a select?
Expected answer: This is best done with the COLUMN command.

7. You want to group the following set of select returns, what can you group on?
Max(sum_of_cost), min(sum_of_cost), count(item_no), item_no
Expected answer: The only column that can be grouped on is the "item_no" column, the rest have aggregate functions associated with them.

8. What special Oracle feature allows you to specify how the cost based system treats a SQL statement?
Level: Intermediate to high Expected answer: The COST based system allows the use of HINTs to control the optimizer path selection. If they can give some example hints such as FIRST ROWS, ALL ROWS, USING INDEX, STAR, even better.

9. You want to determine the location of identical rows in a table before attempting to place a unique index on the table, how can this be done?
Level: High Expected answer: Oracle tables always have one guaranteed unique column, the rowid column. If you use a min/max function against your rowid and then select against the proposed primary key you can squeeze out the rowids of the duplicate rows pretty quick. For example: select rowid from emp e where e.rowid > (select min(x.rowid) from emp x where x.emp_no = e.emp_no); In the situation where multiple columns make up the proposed key, they must all be used in the where clause.

10. What is a Cartesian product?
Expected answer: A Cartesian product is the result of an unrestricted join of two or more tables. The result set of a three table Cartesian product will have x * y * z number of rows where x, y, z correspond to the number of rows in each table involved in the join.

11. You are joining a local and a remote table, the network manager complains about the traffic involved, how can you reduce the network traffic?
Level: High Expected answer: Push the processing of the remote data to the remote instance by using a view to pre-select the information for the join. This will result in only the data required for the join being sent across.

12. What is the default ordering of an ORDER BY clause in a SELECT statement?
Expected answer: Ascending

13. What is tkprof and how is it used?
Level: Intermediate to high Expected answer: The tkprof tool is a tuning tool used to determine cpu and execution times for SQL statements. You use it by first setting timed_statistics to true in the initialization file and then turning on tracing for either the entire database via the sql_trace parameter or for the session using the ALTER SESSION command. Once the trace file is generated you run the tkprof tool against the trace file and then look at the output from the tkprof tool. This can also be used to generate explain plan output.

14. What is explain plan and how is it used?
Level: Intermediate to high Expected answer: The EXPLAIN PLAN command is a tool to tune SQL statements. To use it you must have an explain_table generated in the user you are running the explain plan for. This is created using the utlxplan.sql script. Once the explain plan table exists you run the explain plan command giving as its argument the SQL statement to be explained. The explain_plan table is then queried to see the execution plan of the statement. Explain plans can also be run using tkprof.

15. How do you set the number of lines on a page of output? The width?
Level: Low Expected answer: The SET command in SQLPLUS is used to control the number of lines generated per page and the width of those lines, for example SET PAGESIZE 60 LINESIZE 80 will generate reports that are 60 lines long with a line width of 80 characters. The PAGESIZE and LINESIZE options can be shortened to PAGES and LINES.

16. How do you prevent output from coming to the screen?
Level: Low
Expected answer: The SET option TERMOUT controls output to the screen. Setting TERMOUT OFF turns
off screen output. This option can be shortened to TERM.

17. How do you prevent Oracle from giving you informational messages during and after a SQL statement execution?
Level: Low Expected answer: The SET options FEEDBACK and VERIFY can be set to OFF.

18. How do you generate file output from SQL?
Answer: By use of the SPOOL command

Useful Oracle Queries

1) Display the name of employees along with their annual salary (sal*12) the name of the employee earning highest annual salary should appear first?
Select ename, sal, sal*12 "Annual Salary" from EMP order by "Annual Salary" desc;
2) Display name, salary, Hra, pf, da, TotalSalary for each employee. The out put should be in the order of total salary, hra 15% of salary, DA 10% of salary .pf 5% salary Total Salary will be (salary+hra+da)-pf?
Select ename, sal SA, sal*0.15 HRA, sal*0.10 DA, sal*5/100 PF, sal+ (sal*0.15) + (sal*0.10) -(sal*.05) TOTALSALARY from emp ORDER BY TOTALSALARY DESC;
3) Display Department numbers and total number of employees working in each Department?
Select deptno, count (*) from emp group by deptno;
4) Display the various jobs and total number of employees working in each job group?
Select job, count (*) from emp group by job;
5) Display department numbers and Total Salary for each Department?
Select deptno, sum (sal) from emp group by deptno;
6) Display department numbers and Maximum Salary from each Department?
Select deptno, max (Sal) from emp group by deptno;
7) Display various jobs and Total Salary for each job?
Select job, sum (sal) from emp group by job;
8)Display each job along with min of salary being paid in each job group?
Select job, min (sal) from emp group by job;
9) Display the department Number with more than three employees in each department?
Select deptno, count (*) from emp group by deptno having count (*)>3;
10) Display various jobs along with total salary for each of the job where total salary is greater than 40000?
Select job, sum (sal) from emp group by job having sum (Sal)>40000;
11) Display the various jobs along with total number of employees in each job. The output should contain only those jobs with more than three employees?
Select job, count (*) from emp group by job having count (*)>3;
12) Display the name of employees who earn Highest Salary?
select ename, sal from emp where sal>=(select max(sal) from emp );
13) Display the employee Number and name for employee working as clerk and earning highest salary among the clerks?
select ename,empno from emp where sal=(select max(sal) from emp where job='CLERK') and job='CLERK' ;
14) Display the names of salesman who earns a salary more than the Highest Salary of the Clerk?
select ename,sal from emp where sal>(select max(sal) from emp where job='CLERK') AND job='SALESMAN';
15) Display the names of clerks who earn a salary more than the lowest Salary of any Salesman?
select ename,sal from emp where sal>(select min(sal) from emp where job='SALESMAN') and job='CLERK';
16) Display the names of employees who earn a salary more than that of jones or that of salary greater than that of scott?
select ename,sal from emp where sal>all(select sal from emp where ename='JONES' OR ename='SCOTT');
17) Display the names of employees who earn Highest salary in their respective departments?
select ename,sal,deptno from emp where sal in (select max(sal) from emp group by deptno);
18) Display the names of employees who earn Highest salaries in their respective job Groups?
select ename,job from emp where sal in (select max(sal) from emp group by job);
19)Display employee names who are working in Accounting department?
select e.ename,d.dname from emp e,dept d where e.deptno=d.deptno and d.dname = 'ACCOUNTING';
20) Display the employee names who are Working in Chicago?
select e.ename,d.loc from emp e,dept d where e.deptno=d.deptno and d.loc='CHICAGO';
21) Display the job groups having Total Salary greater than the maximum salary for Managers?
select job ,sum(sal) from emp group by job having sum(sal) >(select max(sal) from emp where job='MANAGER');
22) Display the names of employees from department number 10 with salary greater than that of ANY employee working in other departments?
select ename,deptno from emp where sal>any(select min(sal) from emp where deptno!=10 group by deptno) and deptno=10 ;
23) Display the names of employees from department number 10 with salary greater than that of ALL employee working in other departments?
select ename,deptno from emp where sal>all(select max(sal) from emp where deptno!=10 group by deptno) and deptno=10 ;
24) Display the names of Employees in Upper Case?
select upper(ename) from emp;
25) Display the names of employees in Lower Case?
select Lower(ename) from emp;
26) Display the names of employees in Proper case?
select InitCap(ename)from emp;
27) Find the length of your name using Appropriate Function?
select lentgh('RAMA') from dual;
28) Display the length of all the employee names?
select length(ename) from emp;
29) Display the name of employee Concatinate with Employee Number?
select ename' 'empno from emp;
30) Use appropriate function and extract 3 characters starting from 2 characters from the following string 'Oracle' i.e., the out put should be ac?
select substr('Oracle',3,2) from dual;
31) Find the first occurance of character a from the following string Computer Maintenance Corporation?
select lstr('Computer Maintenance Corporation','a' ) from dual;
32) Replace every occurance of alphabet A with B in the string .Alliens (Use Translate function)
select translate('Alliens','A','B') from Dual;
33) Display the information from the employee table . where ever job Manager is found it should be displayed as Boss?
select ename ,replace(job,'MANAGER','BOSS') from emp;
34) Display empno,ename,deptno from emp table. Instead of display department numbers display the related department name(Use decode function)?
select empno,ename,deptno,Decode(deptno,10,'ACCOUNTING',20, 'RESEARCH' ,30 , 'SALES','OPERATIONS')DName from emp;
35) Display your Age in Days?
select sysdate-to_date('30-jul-1977') from dual;
36) Display your Age in Months?
select months_between(sysdate,to_date('30-jul-1977')) from dual;
37) Display current date as 15th August Friday Nineteen Nienty Seven?
select To_char(sysdate,'ddth Month Day year') from dual;
39) Scott has joined the company on 13th August ninteen ninety?
select empno,ename,to_char(Hiredate,'Day ddth Month year') from emp;
40) Find the nearest Saturday after Current date?
select next_day(sysdate,'Saturday') from dual;
41) Display the current time?
select To_Char(sysdate,'HH:MI:SS') from dual;
42) Display the date three months before the Current date?
select Add_months(sysdate,-3) from dual
43) Display the common jobs from department number 10 and 20?
select job from emp where job in (select job from emp where deptno=20) and deptno=10;
44) Display the jobs found in department 10 and 20 Eliminate duplicate jobs?
select Distinct job from emp where deptno in(10,20);
45) Display the jobs which are unique to department 10?
select job from emp where deptno=10;
46) Display the details of those employees who do not have any person working under him?
select empno,ename,job from emp where empno not in (select mgr from emp where mgr is not null );
47) Display the details of those employees who are in sales department and grade is 3?
select e.ename,d.dname,grade from emp e,dept d ,salgrade where e.deptno=d.deptno and dname='SALES' and grade=3
48) Display thoes who are not managers?
select ename from emp where job!='MANAGER';
49) Display those employees whose name contains not less than 4 characters?
Select ename from emp where length (ename)>=4
50) Display those department whose name start with"S” while location name ends with "K"?
Select e.ename, d.loc from emp e, dept d where d.loc like ('%K') and enamelike ('S%')
51) Display those employees whose manager name is Jones?
Select e.ename Superior, e1.ename Subordinate from emp e, e1 where e.empno = e1.mgr and e.ename='JONES'
52) Display those employees whose salary is more than 3000 after giving 20% increment?
Select ename, sal, (sal+(sal*0.20)) from emp where (sal+(sal*0.20))>3000;
53) Display all employees with their department names?
Select e.ename, d.dname from emp e, dept d where e.deptno=d.deptno
54) Display ename who are working in sales department?
Select e.ename, d.dname from emp e, dept d where e.deptno=d.deptno and d.dname='SALES'
55) Display employee name, dept name, salary, and commission for those sal in between 2000 to 5000 while location is Chicago?
Select e.ename, d.dname, e.sal, e.comm from emp e, dept d where e.deptno=d.deptno and sal between 2000 and 5000
56) Display those employees whose salary is greater than his manager’s salary?
Select e.ename, e.sal, e1.ename, e1.sal from emp e, e1 where e.mgr=e1.empno and e.sal>e1.sal
57) Display those employees who are working in the same dept where his manager is work?
Select e.ename, e.deptno, e1.ename, e1.deptno from emp e, e1 where e.mgr=e1.empno and e.deptno=e1.deptno
58) Display those employees who are not working under any Manager?
Select ename from emp where mgr is null;
59) Display the grade and employees name for the deptno 10 or 30 but grade is not 4 while joined the company before 31-DEC-82?
Select ename, grade, deptno, sal from emp, salgrade where (grade, Sal) in (select grade, Sal from salgrade, emp where sal between losal and hisal) and grade! =4 and deptno in (10,30) and hiredate<'31-Dec-82'
60) Update the salary of each employee by 10% increment that are not eligible for commission?
Update emp set sal= (sal+(sal*0.10)) where comm is null
61) Delete those employees who joined the company before 31-Dec-82 while their department Location is New York or Chicago?
Select e.ename, e.hiredate, d.loc from emp e, dept d where e.deptno=d.deptno and hiredate<'31-Dec-82' and d.loc in('NEW YORK','CHICAGO')
62) Display employee name, job, deptname, and loc for all who are working as manager?
Select e.ename, e.job, d.dname, d.loc from emp e, dept d where e.deptno=d.deptno
and e.empno in (select mgr from emp where mgr is not null)
63) Display those employees whose manager name is Jones and also display their manager name?
Select e.ename sub, e1.ename from emp e, emp e1 where e.mgr=e1.empno and e1.ename='JONES'
64) Display name and salary of ford if his salary is equal to hisal of his grade?
Select ename, grade, hisal, sal from emp, salgrade where ename='FORD' and sal=hisal;
OR
Select grade, sal, hisal from emp, salgrade where ename='FORD' and sal between losal and hisal;
OR
Select ename, sal, hisal, grade from emp, salgrade where ename='FORD' and (grade, Sal) in (select grade, hisal from salgrade,emp where sal between losal and hisal);
65) Display employee name, job, deptname, his manager name, his grade and make an under department wise?
Select e.ename sub, e1.ename sup, e.job, d.dname, grade from emp e1, salgrade, dept d where e.mgr=e1.empno and e.sal between losal and hisal and e.deptno=d.deptno group by d.deptno, e.ename, e1.ename, e.job, d.dname, grade
OR
Select e.ename sub, e1.ename sup, e.job, d.dname, grade from emp e, e1, salgrade, dept d where e.mgr=e1.empno and e.sal between losal and hisal and e.deptno=d.deptno
66) List out all the employee names, job, salary, grade and deptname for every one in a company except ‘CLERK’. Sort on salary display the highest salary?
Select e.ename, e.job, e.sal, d.dname, grade from emp e, salgrade, dept d where (e.deptno=d.deptno and e.sal between losal and hisal) order by e.sal desc
67) Display employee name, job and his manager. Display also employees who are with out managers?
Select e.ename, e1.ename, e.job, e.sal, d.dname from emp e, emp e1, dept d where e.mgr=e1.empno (+) and e.deptno=d.deptno
68) Display Top 5 employee of a Company?

69) Display the names of those employees who are getting the highest salary?
Select ename, sal from emp where sal in (select max (sal) from emp)
70) Display those employees whose salary is equal to average of maximum and minimum?
Select * from emp where sal=(select (max (sal)+min (sal))/2 from emp)
71) Select count of employees in each department where count >3?
Select count (*) from emp group by deptno having count (*)>3
72) Display dname where atleast three are working and display only deptname?
select d.dname from dept d, emp e where e.deptno=d.deptno group by d.dname having count(*)>3
73) Display name of those managers name whose salary is more than average salary of Company?
Select distinct e1.ename, e1.sal from emp e, e1, dept d where e.deptno=d.deptno and e.mgr=e1.empno and e1.sal> (select avg (sal) from emp)

74) Display those managers name whose salary is more than average salary of his employees?
Select distinct e1.ename, e1.sal from emp e, e1, dept d where e.deptno=d.deptno and e.mgr=e1.empno and e1.sal>any (select avg (sal) from emp group by deptno)
75) Display employee name, sal, comm and net pay for those employees whose net pay is greater than or equal to any other employee salary of the company?
Select ename, sal, NVL (comm, 0), sal+NVL (comm, 0) from emp where sal+NVL (comm, 0) >any (select e.sal from emp e)
76) Display those employees whose salary is less than his manager but more than salary of other managers?
Select e.ename sub, e.sal from emp e, e1, dept d where e.deptno=d.deptno and e.mgr=e1.empno and e.salany (select e2.sal from emp e2, e, dept d1 where e.mgr=e2.empno and d1.deptno=e.deptno)
77) Display all employees’ names with total sal of company with each employee name?

78) Find the last 5(least) employees of company?

79) Find out the number of employees whose salary is greater than their managers salary?
Select e.ename, e.sal, e1.ename, e1.sal from emp e, e1, dept d where e.deptno=d.deptno and e.mgr=e1.empno and e.sal>e1.sal
80) Display the manager who are not working under president but they are working under any other manager?
Select e2.ename from emp e1, emp e2, emp e3 where e1.mgr=e2.empno and e2.mgr=e3.empno and e3.job! ='PRESIDENT';
81) Delete those department where no employee working?
Delete from emp where empno is null;
82) Delete those records from emp table whose deptno not available in dept table?
Delete from emp e where e.deptno not in (select deptno from dept)
83) Display those enames whose salary is out of grade available in salgrade table?
Select empno, sal from emp where sal<(select min (LOSAL) from salgrade) OR sal>(select max (hisal) from salgrade)
84) Display employee name, sal, comm and whose net pay is greater than any other in the company?
Select ename, sal, comm, sal+comm from emp where sal+comm>any (select sal+comm from emp)
85) Display name of those employees who are going to retire 31-Dec-99 if maximum job period is 30 years?
Select empno, hiredate, sysdate, to_char (sysdate,'yyyy') - to_char (hiredate,'yyyy') from emp where to_char (sysdate,'yyyy') - to_char (hiredate,'yyyy')=30
86) Display those employees whose salary is odd value?
Select ename, sal from emp where mod (sal, 2)! =0
87) Display those employees whose salary contains atleast 3 digits?
Select ename, sal from emp where length (sal)=3

88) Display those employees who joined in the company in the month of Dec?
Select empno, ename from emp where trim (to_char (hiredate,'Mon'))=trim ('DEC')
89) Display those employees whose name contains A?
Select ename from emp where ename like ('%A%')
90) Display those employees whose deptno is available in salary?
Select ename, sal from emp where deptno in (select distinct sal from emp);
91) Display those employees whose first 2 characters from hiredate - last 2 characters sal?
Select empno, hiredate, sal from emp where trim (substr (hiredate, 1,2))=trim (substr (sal, -2,2));
OR
Select hiredate, sal from emp where to_Char (hiredate,'dd')=trim (substr (sal, -2,2))
92) Display those employees whose 10% of salary is equal to the year joining?
Select ename, sal, 0.10*sal from emp where 0.10*sal=trim (to_char (hiredate,'yy'))
93) Display those employees who are working in sales or research?
Select e.ename from emp e, dept d where e.deptno=d.deptno and d.dname in ('SALES','RESEARCH');
94) Display the grade of Jones?
Select ename, grade from emp, salgrade where (grade, Sal) =(select grade, Sal from salgrade, emp where sal between losal and hisal and ename='JONES')
95) Display those employees who joined the company before 15th of the month?
select ename ,hiredate from emp where hiredate<'15-Jul-02' and hiredate >='01-jul-02';
96) Display those employees who has joined before 15th of the month?
select ename ,hiredate from emp where hiredate<'15-Jul-02'
97) Delete those records where no of employees in particular department is less than 3?
delete from emp where deptno in (select deptno from emp group by deptno having count(*) <3
98) Delete those employeewho joined the company 10 years back from today?
delete from emp where empno in (select empno from emp where to_char(sysdate,'yyyy')- to_char(hiredate,'yyyy')>=10)
99) Display the deptname the number of characters of which is equal to no of employee in any other department?

100) Display the deptname where no employee is working?
select deptno from emp where empno is null;
101) Display those employees who are working as manager?
select e2.ename from emp e1,e2 where e1.mgr=e2.empno and e2.empno is not null
102) Count th number of employees who are working as managers (Using set opetrator)?
select d.dname from dept d where length(d.dname) in (select count(*) from emp e where e.deptno!=d.deptno group by e.deptno)
103) Display the name of the dept those employees who joined the company on the same date?
select a.ename,b.ename from emp a,emp b where a.hiredate=b.hiredate and a.empno!=b.empno
104) Display those employees whose grade is equal to any number of sal but not equal to first number of sal?
select ename,sal,grade ,substr(sal,grade,1) from emp,salgrade where grade!= substr (sal,1,1) and grade = substr(sal,grade,1) and sal between losal and hisal
105) Count the no of employees working as manager using set operation?
Select count(empno) from emp where empno in (select a.empno from emp a intersect select b.mgr from emp b)
106) Display the name of employees who joined the company on the same date?
select a.ename,b.ename from emp a,emp b where a.hiredate=b.hiredate and a.empno!=b.empno;
107) Display the manager who is having maximum number of employees working under him?
select e2.ename,count(*) from emp e1,e2 where e1.mgr=e2.empno group by e2.ename Having count(*)=(select max(count(*)) from emp e1,e2 where e1.mgr=e2.empno group by e2.ename)
108) List out the employee name and salary increased by 15% and express as whole number of Dollars?
select ename,sal,lpad(translate(sal,sal,((sal +(sal*0.15))/50)),5,'$') from emp
147) Produce the output of the emptable "EMPLOYEE_AND JOB" for ename and job ?
Ans: select ename"EMPLOYEE_AND",job"JOB" FROM EMP;
148) List of employees with hiredate in the format of 'June 4 1988'?
Ans: select ename,to_char(hiredate,'Month dd yyyy') from emp;
149) print list of employees displaying 'Just salary' if more than 1500 if exactly 1500 display 'on taget' if less than 1500 display below 1500?
Ans: select ename,sal,
(
case when sal < 1500 then
'Below_Target'
when sal=1500 then
'On_Target'
when sal > 1500 then
'Above_Target'
else
'kkkkk'
end
)
from emp
150) Which query to calculate the length of time any employee has been with the company
Ans: select hiredate, to_char (hiredate,' HH:MI:SS') FROM emp
151) Given a string of the format 'nn/nn' . Verify that the first and last 2 characters are numbers. And that the middle character is '/' Print the expressions 'Yes' IF valid ‘NO’ of not valid. Use the following values to test your solution'12/54', 01/1a, '99/98'?
Ans:

152) Employes hire on OR Before 15th of any month are paid on the last friday of that month those hired after 15th are paid the last friday of th following month .print a list of employees .their hiredate and first pay date sort those who se salary contains first digit of their deptno?
Ans: select ename,hiredate, LAST_DAY ( next_day(hiredate,'Friday')),
(
case when to_char(hiredate,'dd') <=('15') then
LAST_DAY ( next_day(hiredate,'Friday'))
when to_char(hiredate,'dd')>('15') then
LAST_DAY( next_day(add_months(hiredate,1),'Friday'))
end
)
from emp

153) Display those managers who are getting less than his employees salary?
Ans: select a.empno, a.ename, a.sal, b.sal, b.empno, b.ename from emp a, emp b where a.mgr=b.empno and a.sal>b.sal

154) Print the details of employees who are subordinates to BLAKE?
Ans: select a.empno,a.ename ,b.ename from emp a, emp b where a.mgr=b.empno
and b.ename='BLAKE'

FIXED ASSETS

FIXED ASSETS

1. What is unplanned depreciation?
Answer: Unplanned depreciation is a feature used primarily to comply with special
depreciation accounting rules in Germany and the Netherlands. However, you
also can use this feature to handle unusual accounting situations in which
you need to adjust the net book value and accumulated depreciation amounts
for an asset without affecting its cost. Oracle Assets immediately updates
the YTD and LTD depreciation and the net book value of the asset. The
unplanned depreciation expense you enter must not exceed the current net
book value (Cost - Salvage Value - Accumulated Depreciation) of the asset.
2. Can depreciation be suspended for a specified period of time?
Answer: Depreciation can be suspended at any time by changing the depreciate flag
on the book form to NO. Note that the total depreciation to be taken over
the life of the asset (including that incurred in periods the flag was set
to NO) will still be taken over the original life assigned to the asset. If
the asset was added with the depreciate flag set to NO, missed depreciation
will be caught up in the period the flag is changed to YES. If the asset
was added with the depreciate flag set to YES and the flag was later changed
to NO, the missed depreciation will be caught up in the last period of the
asset's ORIGINAL life; suspending depreciation will not extend the period
over which the asset is depreciated.
The Depreciate flag can also be set at the category level.
If you set the depreciate flag at the asset level, this will override the category
depreciate flag which is the default.
If the intention is to never have the asset Depreciate then the flag Depreciate
flag should be set to 'No' for the life of the asset or the asset can be entered
into the system fully reserved.
3. Can depreciation expense be manually input to override the system?
Answer: Depreciation reserve adjustments can be made to a TAX book. From Release
10.7, with unplanned depreciation you may manually override the depreciation
amount taken in the Corporate book. The depreciation amount cannot be
greater than the net book value of the asset.
4. How does the Depreciate When Placed In Service flag on my prorate
convention affect the calculation and allocation of depreciation?
Answer: With the exception of the method type Calculated Straight Line,
depreciation for the year is calculated based on the prorate date which maps
to a prorate period and rate on the prorate calendar. This total amount is
then allocated back to the individual periods in the year. If this flag is
set to NO, the years depreciation will be spread over the periods beginning
with the prorate date. If the flag is set to YES, the years depreciation
will be spread over the periods beginning with the date placed in service.
Note that total depreciation for the year remains unchanged, only
depreciation per period will differ.
When the method type Calculated Straight Line is used, this flag has no
effect. Yearly depreciation will be calculated as recoverable cost/life,
and allocated beginning with the prorate date.
5. GAAP defines two types of changes; changes in estimates which are to be
handled prospectively and errors which are to be retroactively corrected.
What Oracle functionality addresses these?
Answer: Expense an adjustment for correction of an error, amortize the adjustment
for a change in estimate.
6. How do I set up Oracle Assets to charge a half-month's depreciation in the
first and last periods of the assets life?
Answer: You must do the following:
a. Set up a prorate CALENDAR with semi-monthly periods. So your prorate
calendar will have 24 periods per fiscal year.
Example:
Period 1: Jan 01 - Jan 15
Period 2: Jan 16 - Jan 31
Period 3: Feb 01 - Feb 15
Period 4: Feb 16 - Feb 28
Period 5: Mar 01 - Mar 15 ...

b. Set up a prorate CONVENTION that maps the appropriate dates to the
middle of the month.
Example:
Jan 01 - Jan 31 map to Jan 16
Feb 01 - Feb 28 map to Feb 16
Mar 01 - Mar 31 map to Mar 16 ...

c. Assign your book to the appropriate prorate CALENDAR in the Book
Controls form. (You will also probably want it to depreciate EVENLY).

d. Set the default prorate convention to the appropriate mid-month
convention in the Default Depreciation Rules zone of the Asset
Categories form. You can also specify the prorate CONVENTION in the
Books window during the Detail Additions process.

Now when the depreciation program processes an asset whose date placed in
service is Jan 10, it will use the prorate convention to map that date to a
PRORATE DATE of Jan 16, and it will use the prorate date to map to
PRORATE PERIOD #2 in your prorate calendar. Thus, if you are running
depreciation for January (note that your DEPRECIATION CALENDAR can still
be monthly), you will get half a month's worth of depreciation for January.

*** It is not enough to set the prorate convention to a mid-month convention -
*** you must also set the prorate CALENDAR to be semi-monthly.
7. What is the difference between the new What-If feature and the old
depreciation projections functionality?
Answer: Using What-If Analysis, you can model depreciation scenarios for any number
of future periods based on depreciation attributes different from what you
have currently set up for the asset. Hence the name: What If Analysis.

Using Depreciation Projection, you can project depreciation expense based
on the asset's current depreciation method, life, etc.

Additionally, What-If Analysis is very flexible in allowing you to select a
subset of assets for analysis. Selection criteria include Range of Asset
Numbers, Range of Dates Placed in Service, Asset Category etc. For
Depreciation Projections, you must specify a BOOK and the program selects
all active assets for that book.
8. When I run depreciation I get the following error:
"Error: function fafbgcc returned failure (called from fadoflx) Getting
account CCID"
How do I correct this problem?
Answer: Set the profile options FA:PRINT_DEBUG and FA:DEPRN SINGLE to YES and
rerun depreciation. Make note of the asset number and distribution id.
Depreciation tries to build a code combination id (CCID) for one of the
following:

Asset Cost Account/CIP Cost Acct (Current Period Asset Clearing
Account)/CIP Clearing Acct (Current Period Adds) Depreciation Expense
Account (Prior Period Additions)

Check whether Allow Dynamic Inserts is being allowed for the Accounting
Flexfield (AFF).
Navigation:
Setup -> Financials -> Flexfields -> Segments -> Key
Query for Oracle General Ledger - Accounting Flexfield
If the Allow Dynamic Inserts box is not checked, unfreeze the flexfield
definition, check the box, refreeze and Compile. If it is already checked,
that means the combination generated is not valid. To find out what
combination is being generated, do the following:

Find out which category the asset belongs to by querying for the asset in
the Asset Workbench (Navigation: Assets -> Asset Workbench). Then query for
the asset category/book combination in the Asset Categories form
(Navigation: Setup -> Asset System -> Asset Categories). Using the Help ->
Tools -> Examine function from the menu, get the following information:

Account segment value for Asset Cost/Cost Clearing accounts
(or CIP Cost/CIP Clearing accounts if asset is CIP)
Code combination id (CCID) associated with these accounts

From the Book Controls form, you need to get the Default CCID for the
book utilizing Help -> Tools -> Examine method
(N)Setup -> Asset System -> Book Controls.

From the Inquiry/Financial Information form, you need to get the
distribution CCID for the asset utilizing the same method
(N)Inquiry -> Financial Information -> Assignments form.

Once you have the parameters, in Release 11 run the script faxagtst.sql
to see what combination is getting built and why it is failing.
For details on using faxagtst.sql, see Note 1062849.6

In Release 10.7, you will need to perform a Flexbuilder Test in the
application.
(N)Setup -> Financials -> Flexfields -> Flexbuilder -> Test
9. What depreciation methods are supported within Oracle Assets?
Answer: You may choose from the following:
Straight-line
Declining balance
Sum-of-year's digits
Units of production
ACRS and MACRS
Flat rate
Diminishing value
Bonus depreciation
In Release 11i, you will also be able to create formula-based methods
for depreciation.
10. When should I run the depreciation program?
Answer: For Release 10.7 and 11:
You should run depreciation when you are ready to close your depreciation
period. Depreciation cannot be rolled back once run. Since the depreciation
program closes the period, you should make sure that you entered all your
transactions for the current period. If you forget to enter a transaction in
the current period, you can enter a retroactive addition, transfer, or
retirement transaction in the following period. Oracle Assets will not
calculate adjustments to depreciation until you run depreciation again.

For Release 11i:
You can now run Depreciation as many times as you would like without closing
the period. When you are ready to close the period, on your final
Depreciation run, you would check the Close Period button on the form.
You have the capability in 11i to rollback depreciation. So if you run
Depreciation and you do not like the results, you can rollback Depreciation,
make your changes, and submit Depreciation again. Once the final Depreciation
has been run and the period is closed, you cannot rollback Depreciation for
the period. If you are closing the last period for a fiscal year, you cannot
enter a retroactive retirement for a period after the end of the year.
11. How often can I run depreciation?
Answer: For Release 10.7 and 11:
You can run depreciation only once per depreciation period. When you run
depreciation and close the period, you cannot reopen that period. You must
run depreciation for each corporate and tax book; Oracle Assets does not run
depreciation automatically for a tax book when you run depreciation for the
associated corporate book. Run Mass Copy to update your tax book prior to
running depreciation for the tax book.

For Release 11i:
You can run Depreciation as many times as you like. When you are ready to
close the period, on your last Depreciation run, check the Close Period
box on the Run Depreciation form.
12. What happens if I run depreciation when there are retirements or
reinstatements pending?
Answer:
When you submit depreciation, the process automatically runs the Calc
Gain/Loss (FARET) program to calculate gains and losses for any pending
retirements. You also can run FARET independently in order to reduce
depreciation processing time.
13. What is the difference between depreciation projections and depreciation?
Answer: Depreciation projections use a completely separate set of modules than the
Depreciation program. Depreciation projections do not take into account
adjustments entered in the current period, so any new retirements, transfers,
or adjustments will not effect the projection. Projections simply take a
snapshot of the asset at the start date of the projection and project
depreciation expense based on that information.
14. What happens if depreciation encounters an error? How do I proceed?
Answer: For Release 10.7 and 11:
If the depreciation program encounters an error, the program will stop and
perform a rollback to the previous commit. The program automatically resets
the DEPRN_RUNNING_FLAG to NO. If the error is straight forward, such as
Out of rollback segments, you can try to correct the error and then resubmit
the depreciation program. If the error is more serious, such as an operating
system error, you should contact Support before taking any further actions.

For Release 11i:
If the Depreciation program encounters and error, it will continue to
process all of the assets. The errored assets will appear in your logfile
so that you can fix them and resubmit Depreciation. Depreciation will then
only process the corrected assets.
15. What can I do to reduce processing time for the depreciation program?
Answer: Run Calc Gain/Loss several times throughout the period (this can be run
as often as you want). Then, when you finally run depreciation, the
Calc Gain/Loss program will process only the remaining retirements or
reinstatements. Ensure that your tables are not fragmented. Ask your
database administrator (DBA) to check for fragmentation problems. If
fragmentation exists, have the DBA export and reimport the tables, or
recreate them.

For Release 11 and 11i:
In addition to running Calculate Gains and Losses throughout the period,
run the Generate Accounts program before running Depreciation (N)Other
-> Requests -> Run. This will create the new code combinations needed so
that when you run Depreciation, the Generate Accounts program will not
detect any new asset with code combinations that need to be built, which
will greatly enhance overall performance.

For 11i customers, if the concurrent program (FAGDA) does not appear in the LOV
using Standard Report Submission (SRS) form, then please see Note 124955.1.
16. How does the depreciation program handle the end of a fiscal year?
Answer: At the end of a fiscal year, the depreciation program runs a short module
to prepare Oracle Assets for the next fiscal year. This module runs
automatically during the depreciation program. The fiscal years program
runs if the current period is the last period in the fiscal year. This
occurs when the period number of the current period = NUMBER_PER_FISCAL_YEAR
in the table FA_CALENDAR_TYPES. The fiscal years program checks if there are
rows defined for the next fiscal year in FA_DEPRN_PERIODS, FA_FISCAL_YEAR,
FA_CALENDAR_PERIODS, and FA_CONVENTIONS. If rows do not already
exist, the fiscal years program creates them.

For Release 11i:
Because of changes for the formula-based depreciation methods, you are now
required to create your fiscal year and calendars for the current fiscal
year + 1. Otherwise, you will be unable to run depreciation successfully.
17. What is the process flow for running Depreciation in 11i?
Answer:There have been several changes made by development to make the Depreciation/Create
Journals Process go much smoother for 11i. To take advantage of these changes, you must be on minipack H (2115788) and stand alone Patch 2130639.
In 11i, you may run Depreciation without closing the period. This allows you to check Depreciation
and make any necessary adjustments before closing the period.
The process should be:
1. Run Depreciation (without closing the period)
2. Run Create Journals
3. Review reports in FA and GL to determine if everything look correct
If everything is correct,
- Resubmit Depreciation (closing the period)
- Create Journals does not need to be ran again
If corrections are necessary,
- Rollback Journals
- Rollback Depreciation
- Make corrections
- Repeat steps 1-3.
With the application of the new code mentioned above, if you try to rollback
Depreciation without rolling back Create Journals, Rollback Depreciation will
error telling you that you need to rollback Create Journals.
18. What is the difference between the 'B' row and the 'D' row in the
FA_DEPRN_DETAIL table?
Answer:The 'B' (Books) row is added to the FA_DEPRN_DETAIL table when the asset is added
to Oracle Assets. There will only be one Books row per distribution in the
FA_DEPRN_DETAIL table. The 'D' (Depreciation) rows are added when Depreciation
is ran. There will be one row for each period and distribution that
Depreciation is ran for.
19. What is the Depreciation Adjustment account used for?
Answer:When you use the functionality of Tax Reserve Adjustment for the prior fiscal
of a Tax book the Depreciation Adjustment Account is used.
20. How can I add assets to a closed period (after Depreciation has been ran)?
Answer:Many types of transactions within Oracle Assets can be entered with
retro-active effective dates - (please consult the User Guide to see
if this is possible for the transactions you wanted to enter).
For the period accidentally closed in Assets, you can accrue for the
financial impact of these transactions using manual GL journals.
Oracle Assets will then catch up any financial impact of the transactions
when you Create Journal Entries for the next period. You can then reverse
out your accruals.