在将sybase查询转换为oracle时无法获得所需的输出

时间:2017-03-10 16:04:52

标签: sql oracle sybase

我们正在从Sybase迁移到Oracle。 我有以下Sybase查询更新表。

Update LssiFacility set regionCd = r.opsRgnNo, districtCd = d.opsDistNo, 
                 locDeletedFlg = \"N\" 
                 FROM  GroundOpsRgn r, GroundOpsDist d 
                 WHERE LssiFacility.regionLocId = r.opsRgnCd 
                 AND   r.opsRgnNo = d.opsRgnNo 
                 AND   LssiFacility.districtId = opsDistCd 
                 AND   LssiFacility.regionLocId != \" \" 
                 AND   LssiFacility.districtId != \" \" 
                 AND  (LssiFacility.regionCd = \" \" 
                 or    LssiFacility.districtCd = \" \") 
                 AND   LssiFacility.locDeletedFlg != \"Y\" 
                 AND expriationDate <= \"99991231\" 
                 AND expriationDate > getdate()

我使用上面的sybase查询修改了下面的oracle查询。

UPDATE lssi_facility l SET ( region_cd, district_cd, loc_deleted_flg ) = ( 
                           SELECT r.ops_rgn_no, d.ops_dist_no, 'N' 
                           FROM  ground_ops_rgn r, ground_ops_dist d 
                           WHERE trim(l.region_loc_id) = trim(r.ops_rgn_cd) 
                           AND r.ops_rgn_no = d.ops_rgn_no 
                           AND l.district_id = d.ops_dist_cd 
                           AND trim(l.region_loc_id) IS NOT NULL 
                           AND trim(l.district_id) IS NOT NULL 
                           AND (trim(l.region_cd) IS NULL OR  trim(l.district_cd) IS NULL) 
                           AND l.loc_deleted_flg != 'Y') 
                           WHERE trim(l.region_loc_id) IS NOT NULL 
                           AND trim(l.district_id) IS NOT NULL 
                           AND (trim(l.region_cd) IS NULL OR  trim(l.district_cd) IS NULL) 
                           AND l.expriation_date <= '99991231' 
                           AND l.expriation_date > to_char(SYSDATE,'YYYYMMDD')

我没有在oracle中得到理想的结果。 Sybase工作正常,但在oracle中,region_cd和district_cd值没有更新。

谢谢, 和Sandeep

0 个答案:

没有答案