SELECT sec_office,
sec_dept,
sec_cls,
sec_agt,
sec_year,
sec_id,
sec_endst,
sdffl.sdf_sec,
scl_code,
sec_ccy,
sdffl.sdf_prmpct,
sdffl.sdf_prm,
sdffl.sdf_rftr,
sdffl.sdf_rliab,
sdffl.sdf_rflag,
sdffl.sdf_cdate,
sdffl.sdf_adate,
sdffl.sdf_cuser,
sdffl.sdf_auser,
sdffl.sdf_lock,
sdffl.sdf_liabtype,
0 rep_count,
sdf_tsiccy,
sdf_tsi,
sdf_acced,
sdf_retn,
sdf_tty,
sdf_fac,
sdf_perconf,
sdf_dicyn
FROM sclfl, sdffl, secfl, clsfl
where
cls_code = :as_cls and
scl_grp1 = :as_cls and ( scl_pkgseq > 0 or ( cls_main = '1' and scl_code = scl_grp1 ) ) and
sec_office = :as_office and sec_dept = :as_dept and sec_cls = :as_cls and
sec_agt = :as_agt and sec_year = :ai_year and sec_id = :as_id and
sec_sec = :as_sec and sec_endst = :ai_endst and
scl_grp1 = sdf_office (+)
order by scl_pkgseq