Posts

Showing posts from October, 2022

Timestamp with milli/micro/nano seconds

Image
As part of performance and run time of a query or a function we might need to capture time in milli/micro/ nano seconds. Below snippets would help in such scenarios: By default  localtimestamp will give upto 6 decimal places of a sec. to get nano sec upto 9 decimal use  localtimestamp(9) declare l_starttime timestamp(9); l_endtime timestamp(9); l_count number:=0; l_Diff number:=0; begin select localtimestamp(9) into l_starttime from dual;  dbms_output.put_line('Start Time: ' || l_starttime);   select count(*) into l_count from PO_line_locations_all pll, po_headers_all PHA where pll.po_header_id = pha.po_header_id and exists (select 1 from po_requisition_lines_all prl,po_requisition_headers_all prh               where prl.requisition_header_id = prh.requisition_header_id                 and prl.blanket_po_header_id = pha.po_header_id) and pll.po_header_id = <enter header id>; select localtimestamp(9) into l_endtime from dual;  dbms_output.put_line('End Time: ' || l