Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
set serveroutput on format wrap
declare
hold_cust_count varchar2;
FUNCTION j_cust_cnt_prem_f
(
IN_EQUIP_STN_NO IN VARCHAR2,
IN_CIRCUIT_ID IN VARCHAR2,
IN_DNI_EQUIP_TYPE IN VARCHAR2
)
RETURN varchar2
IS
OUT_COUNT_CUST varchar2;
BEGIN
BEGIN
SELECT COUNT(premise_custno_id)
INTO OUT_COUNT_CUST
FROM premise
WHERE strctur_no IN
(
SELECT DISTINCT dni.strctur_no
FROM dni,
(
SELECT equip_stn_no
FROM jeacust.j_dni_connectivity_v jc
START WITH decode(IN_DNI_EQUIP_TYPE, 'SSUB', jc.tie_equip_stn_no,
jc.equip_stn_no) = IN_EQUIP_STN_NO
CONNECT BY PRIOR jc.equip_stn_no = jc.tie_equip_stn_no
AND jc.valid_link_flg = 'T'
AND jc.circt_id = IN_CIRCUIT_ID
) jc_inline
WHERE dni.equip_stn_no = jc_inline.equip_stn_no
)
AND cust_type_cd = 'ELEC' ;
EXCEPTION
WHEN OTHERS
THEN
OUT_COUNT_CUST := 'ERROR';
END;
RETURN (OUT_COUNT_CUST );
END;
begin
dbms_output.enable(1000000);
For x in (select D.SUBST_ID "SUBSTATION ID", s.subst_nam "SUBSTATION NAME",
SUBSTR(c.circt_nam,instr(c.circt_nam,'_',1)+1,6)"CIRCUIT NAME",
d.dni_equip_type "DEVICE TYPE",
DECODE(d.dni_equip_type, 'RECL', d.equip_serial_no, 'SSUB', ' ', d.display_text) "DEVICE ADDRESS",
d.equip_stn_no, d.circt_id,d.dni_equip_type) "NUMBER OF CUST"
from dni D, SUBSTATION S, circuit c
where S.SUBST_ID = D.SUBST_ID
AND d.circt_id = c.circt_id
and D.DNI_EQUIP_TYPE in ('SSUB', 'RECL', 'SWITCH')
GROUP BY s.subst_nam, D.subst_id, c.circt_nam, d.dni_equip_type, d.equip_serial_no, d.display_text,
d.equip_stn_no, d.circt_id,d.dni_equip_type
order by s.subst_nam, D.subst_id, c.circt_nam, d.dni_equip_type, d.equip_serial_no, d.display_text,
d.equip_stn_no, d.circt_id,d.dni_equip_type) loop
hold_cust_count := j_cust_cnt_prem_f(x.equip_stn_no, x.circt_id,x.dni_equip_type);
dbms_output.put_line('-- Formatted output from each row, above, goes here.');
-- In the dbms_output.put_line statement, above, be sure to refer to each expression from the
-- CURSOR FOR LOOP with the prefix "x.<expression".
end loop;
end;
/