Thursday 23 May 2013



CUSTOMER DUMP

SELECT DISTINCT
a.customer_name
,a.customer_name_phonetic alternate_name
,a.customer_number
,a.party_number
,ps.party_site_number site_number
,d.LOCATION
,a.orig_system_reference customer_ref
,b.orig_system_reference address_ref
,b.attribute3 site_classification
,b.attribute4 legacy_customer_num
,b.org_id
,hou.name circle_name
,d.SITE_USE_CODE
,d.PRIMARY_FLAG
,e.creation_date
,getlogin(e.created_by)
,ADDRESS1
,ADDRESS2
,ADDRESS3 ,
B.CITY,
b.STATE,
B.COUNTRY ,
B.POSTAL_CODE,
decode(a.STATUS,'A','Active','I','Inactive',b.STATUS) cust_header_status,
decode(b.STATUS,'A','Active','I','Inactive',b.STATUS) cust_site_status,
(select f.PARTY_NAME object
from HZ_RELATIONSHIPS_V f
where
   f.subject_id = a.party_id
   and rownum = 1) object,
d.SITE_USE_ID
FROM ra_customers a,
ra_addresses_all b,
hz_party_sites ps,
hz_cust_accounts_all c,
hz_cust_site_uses_all d,
hz_cust_acct_sites_all e,
hr_operating_units hou
--HZ_RELATIONSHIPS_V f
WHERE a.party_id=b.party_id
AND b.party_id=c.PARTY_ID
AND e.PARTY_SITE_ID=b.PARTY_SITE_ID
AND e.party_site_id=ps.party_site_id
AND d.org_id = hou.organization_id
AND e.cust_account_id = c.cust_account_id
AND e.cust_account_id = a.customer_id --------This code added by SIVA Reddy.
AND e.cust_acct_site_id = d.cust_acct_site_id
AND b.org_id=hou.ORGANIZATION_ID
--and nvl(a.party_id,1)  = nvl(f.subject_id,1)
AND b.org_id = 109
ORDER BY ps.party_site_number

Sunday 14 April 2013

Global Temporary Tables for tuning


Global Temporary Tables


Applications often use some form of temporary data store for processes that are to complicated to complete in a single pass. Often, these temporary stores are defined as database tables or PL/SQL tables. In Oracle 8i, the maintenance and management of temporary tables can be delegated to the server by using Global Temporary Tables.

Creation of Global Temporary Tables


The data in a global temporary table is private, such that data inserted by a session can only be accessed by that session. The session-specific rows in a global temporary table can be preserved for the whole session, or just for the current transaction. The ON COMMIT DELETE ROWS clause indicates that the data should be deleted at the end of the transaction.

CREATE GLOBAL TEMPORARY TABLE my_temp_table (
  column1  NUMBER,
  column2  NUMBER
) ON COMMIT DELETE ROWS;

In contrast, the ON COMMIT PRESERVE ROWS clause indicates that rows should be preserved until the end of the session.

CREATE GLOBAL TEMPORARY TABLE my_temp_table (
  column1  NUMBER,
  column2  NUMBER
) ON COMMIT PRESERVE ROWS;

Miscellaneous Features


  • If the TRUNCATE statement is issued against a temporary table, only the session specific data is trucated. There is no affect on the data of other sessions.
  • Data in temporary tables is stored in temp segments in the temp tablespace.
  • Data in temporary tables is automatically deleted at the end of the database session, even if it ends abnormally.
  • Indexes can be created on temporary tables. The content of the index and the scope of the index is the same as the database session.
  • Views can be created against temporary tables and combinations of temporary and permanent tables.
  • Temporary tables can have triggers associated with them.
  • Export and Import utilities can be used to transfer the table definitions, but no data rows are processed.
  • Statistics on temporary tables are common to all sessions. Oracle 12c allows session specific statistics.
  • There are a number of restrictions related to temporary tables but these are version specific.