Thursday, October 20, 2022

Next row and previous row in the table - LAG or Lead function

LAG or Lead function 


select order_no, installment_id, installment_id2, due_date , due_date2,number_of_days

from 

(

select t.order_no, 

        installment_id,          

        LEAD (installment_id,1) OVER (PARTITION BY t.order_no ORDER BY installment_id) AS installment_id2,

        due_date,

        LEAD (due_date,1) OVER (PARTITION BY t.order_no ORDER BY due_date) AS due_date2,

        

        (LEAD (due_date,1) OVER (PARTITION BY t.order_no ORDER BY due_date)-due_date) number_of_days


  from C_CREDIT_PAYMENT_PLAN p , PAYMENT_PLAN c, CUSTOMER_ORDER_CFV t

where p.invoice_id=c.invoice_id

and p.order_no=t.order_no

and c_early_settle <>'TRUE'

and PARTY_TYPE_DB='CUSTOMER'

--and t.order_no='L500592'

and CUSTOMER_ORDER_API.GET_C_LEASING_ACCOUNT_STATUS(t.ORDER_NO)<>'Closed'

and installment_id>1

and CUSTOMER_ORDER_API.GET_ORDER_ID(t.ORDER_NO) <>'MIG'

where number_of_days>31



//////



select order_no, installment_id, installment_id2, due_date , due_date2,number_of_days

from 

(

select t.order_no, 

        installment_id,          

        LAG (installment_id,1) OVER (PARTITION BY t.order_no ORDER BY installment_id) AS installment_id2,

        due_date,

        LAG (due_date,1) OVER (PARTITION BY t.order_no ORDER BY due_date) AS due_date2,

        

        (LAG (due_date,1) OVER (PARTITION BY t.order_no ORDER BY due_date)-due_date) number_of_days


  from C_CREDIT_PAYMENT_PLAN p , PAYMENT_PLAN c, CUSTOMER_ORDER_CFV t

where p.invoice_id=c.invoice_id

and p.order_no=t.order_no

and c_early_settle <>'TRUE'

and PARTY_TYPE_DB='CUSTOMER'

and t.order_no='L500592'

and CUSTOMER_ORDER_API.GET_C_LEASING_ACCOUNT_STATUS(t.ORDER_NO)<>'Closed'

and installment_id>1

and CUSTOMER_ORDER_API.GET_ORDER_ID(t.ORDER_NO) <>'MIG'

--where number_of_days>31


Monday, October 10, 2022

AWR report

 ps -ef|grep pmon


sqlplus / as sysdba


select * from v$version;


SQL> show parameter control_management_pack_access;


NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

control_management_pack_access       string      DIAGNOSTIC+TUNING



exit;


[oracle@ifsrepdb ~]$ cd $ORACLE_HOME/rdbms/admin/@awrrpt.sql


/*

[oracle@ifsrepdb ~]$ cd $ORACLE_HOME/

[oracle@ifsrepdb dbhome_1]$ cd 


[oracle@ifsrepdb admin] ls -lrt


[oracle@ifsrepdb admin]$ ls -lrt awrrpt*


*/



[oracle@ifsrepdb admin]$ sqlplus / as sysdba


SQL> @awrrpt.sql


Specify the Report Type

~~~~~~~~~~~~~~~~~~~~~~~

AWR reports can be generated in the following formats.  Please enter the

name of the format at the prompt.  Default value is 'html'.


'html'          HTML format (default)

'text'          Text format

'active-html'   Includes Performance Hub active report


Enter value for report_type: html




Enter value for num_days: 2




Enter value for snapshot start: 100


Enter value for snapshot end: 102



Enter report format name: awrreportdb.html






exit





ls -lrt 


pwd 


/u01/app/oracle/product/19.3.0/dbhome_1/rdbms/admin



go to WinSip 




To generate a PDF using JavaScript in Oracle APEX from a collection

  To generate a PDF using JavaScript in Oracle APEX from a collection, you can follow these steps: 1. Create a button or link on your APEX p...