帆软用户cp0VecIO4p(提问者)SELECT a.hdrid
FROM fr_project_hdr a
$IF(sql(\"ztsc\",\"SELECT count(1) from fr_project_cstattribute where 1=1 and hdrid= \'${项目名称}\' and dtlid=nvl(\'${子项目名称}\',0)
AND CSTBUTE=2,1,1)>=1,\",(SELECT a.hdrid,
a.dtlid,
a.GKUNIFYCST,
b.cstid
FROM fr_project_cst a,
(SELECT ID CSTID,SINOPHARM_ID FROM CMSXTY.SPM_PRODUCER_EXT@CX_CMS) b
WHERE a.CSTBUTE=2 AND a.hdrid=\'\" + 项目名称 + \"\' AND a.dtlid=nvl(\'\" + 子项目名称 + \"\',0)
AND a.GKUNIFYCST=b.SINOPHARM_ID
) C\",\"\")
WHERE 1=1
$IF(sql(\"ztsc\",\"SELECT count(1) from fr_project_cstattribute where 1=1 and hdrid= \'\" + 项目名称 + \"\' and dtlid=nvl(\'\" + 子项目名称 + \"\',0)
AND CSTBUTE=2,1,1)>=1,\"a.id=c.hdrid(+) and a.dtlid=c.dltid(+)\")