我有允许有两列(CAGE,HCC)空值的表。我想在我的程序中显示重复的记录,我是这样写的。
FOR REC IN (SELECT LOCATION, NIIN, INVL_DATE, CAGE,
HCC,SUM(CA_QTY) AS SUM_CA,SUM(COST_QTY) AS SUM_COST,COUNT(*) FROM INVENTORY
GROUP BY LOCATION, NIIN, INVL_DATE,
CAGE, HCC
HAVING COUNT(*)>1)
LOOP
VAR_LOC_NAME := REC.LOCATION;
VAR_NIIN := REC.NIIN;
VAR_DATE := REC.INVL_DATE;
VAR_CAGE := REC.CAGE;
VAR_HCC := REC.HCC;
VAR_CA_QTY := REC.SUM_CA;
VAR_COST_QTY := REC.SUM_COST;
FOR REC1 IN (SELECT SNO FROM INVENTORY WHERE LOCATION=VAR_LOC_NAME AND
NIIN=VAR_NIIN AND TUNC(INVL_DATE)=TRUNC(TO_DATE(VAR_DATE,'DD-MM-YY')) AND
CAGE=VAR_CAGE AND HCC=VAR_HCC)
LOOP
DBMS_OUTPUT.PUT_LINE('GET NUMBER '||REC1.SNO);
END LOOP;
end loop;
但对于 CAGE 和 HCC 的空值,它不起作用。仅供参考:我正在使用 oracle 11g