Sunday, 8 July 2018

Oracle Tax Regime and Operating Unit Join Query

select
distinct a.tax_regime_code,c.name,c.* from ZX_RATES_B a,zx_accounts b, hr_operating_units c
where a.tax_rate_id=b.tax_account_entity_id
and b.internal_organization_id=c.organization_id;

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;