select
  a.cucd, a.cshcd, a.cshnm, a.cszip, a.csad1||' '||a.csad2 csad,
  a.cstel, a.csfax
from afm036 a
where (:ccd is null or a.cucd = :ccd)							  /* 完全一致 */
  and (:cd is null or a.cshcd like :cd||'%')				/* 前方一致 */
  and (:nm is null or (upper(comnpack.MultiTOSingleBytesEx(a.cshnm))
                                like '%'||upper(comnpack.MultiTOSingleBytesEx(:nm))||'%') )		/* 前後曖昧 */

  and (:zip is null or (upper(comnpack.MultiTOSingleBytesEx(a.cszip))
                                like '%'||upper(comnpack.MultiTOSingleBytesEx(:zip)||'%')) )	/* 前後曖昧 */
  and (:sadd is null or (upper(comnpack.MultiTOSingleBytesEx(a.csad1||a.csad2))
                                like '%'||upper(comnpack.MultiTOSingleBytesEx(:sadd))||'%'))	/* 前後曖昧 */
  and (:tel is null or (upper(comnpack.MultiTOSingleBytesEx(a.cstel))
                                like '%'||upper(comnpack.MultiTOSingleBytesEx(:tel)||'%')) )	/* 前後曖昧 */
  and (:fax is null or (upper(comnpack.MultiTOSingleBytesEx(a.csfax))
                                like '%'||upper(comnpack.MultiTOSingleBytesEx(:fax)||'%')) )	/* 前後曖昧 */
order by a.cucd, a.cshcd
