insert into metadata_statistics(rundate, metadata_defn, order_sequence, total_entries, metadata_id) 
select to_date(sysdate,'YYYY-MM-DD-HH24:MI:SS'), 'SizePerScript', rownum, totals, id from 
(select length(dbl_blob) totals, dbl_doc_id id
from dhi, dbl
where dbl_doc_id = dhi_doc_id
and   dbl_cmp_id = dhi_cmp_id
and   dbl_cmp_id = 40001
and substr(dhi_doc_path,1,9) = '/scripts/'
order by totals desc);
commit;
quit;
