Sunday, 8 July 2018

Oracle Database Version Query

SELECT * FROM V$INSTANCE;
SELECT * FROM V$VERSION;
select * from PRODUCT_COMPONENT_VERSION;


------Database Plateform Version Query------


declare
l_version varchar2(255);
l_compatibility varchar2(255);
begin
dbms_utility.db_version( l_version, l_compatibility );
dbms_output.put_line( l_version );
dbms_output.put_line( l_compatibility );
end;

 select dbms_utility.port_string from dual; 

Oracle Credit-Debit Invoice Reference Invoice No Query

SELECT
SUBSTR (SYS_CONNECT_BY_PATH (trx_number , ','), 2) CM_DM_REF_INV_NO
--- INTO v_OU_VAT_REG_NO
      FROM (SELECT rcta2.trx_number,ROW_NUMBER () OVER (ORDER BY rcta2.trx_number ) rn, COUNT (*) OVER () cnt
    FROM RA_CUSTOMER_TRX_ALL rcta1,
         RA_CUSTOMER_TRX_ALL rcta2,
         AR_RECEIVABLE_APPLICATIONS_ALL araa
   WHERE --rcta1.trx_number = CM_DM_IINV_NO
   rcta1.customer_trx_id=CM_DM_CUST_TRX_ID
     AND araa.status = 'APP' --applied
     AND araa.display = 'Y'  --Not UNapplied
     AND rcta1.customer_trx_id = araa.customer_trx_id
     AND rcta2.customer_trx_id = araa.APPLIED_CUSTOMER_TRX_ID
ORDER BY apply_date ASC
)
     WHERE rn = cnt
START WITH rn = 1
CONNECT BY rn = PRIOR rn + 1;

Oracle Item Category Extract Query

select
msi.segment1 Item_Code,  msi.DESCRIPTION Item_Desc,
mcs.CATEGORY_SET_NAME, mck.CONCATENATED_SEGMENTS,
mck.SEGMENT1, mck.SEGMENT2, mck.SEGMENT3, mck.SEGMENT4, mck.SEGMENT5,
mck.SEGMENT6, mck.SEGMENT7, mck.SEGMENT8, mck.SEGMENT9, mck.SEGMENT10,
mck.SEGMENT11, mck.SEGMENT12, mck.SEGMENT13, mck.SEGMENT14, mck.SEGMENT15,
mck.SEGMENT16, mck.SEGMENT17, mck.SEGMENT18, mck.SEGMENT19, mck.SEGMENT20
from mtl_system_items_b msi, mtl_item_categories mic, MTL_CATEGORIES_KFV MCK, MTL_CATEGORY_SETS_TL mcs
where msi.INVENTORY_ITEM_ID = mic.INVENTORY_ITEM_ID and msi.ORGANIZATION_ID = mic.ORGANIZATION_ID
and mic.CATEGORY_ID = mck.CATEGORY_ID
and mcs.CATEGORY_SET_ID = mic.CATEGORY_SET_ID and mcs.LANGUAGE = userenv('Lang')
and msi.ORGANIZATION_ID = :P_Org_id