所以基本上我想从不同的表中获取所有信息,但我有一个麻烦,当我使用select into时,它说没有找到数据
BEGIN
FOR id_rec IN (SELECT customertrxid FROM comprobante) LOOP
current_id := id_rec.customertrxid;
DBMS_OUTPUT.PUT_LINE('ID: ' || current_id);
SELECT sum(IMPORTE) into SumaImporteCon FROM Conceptos where current_id = customertrxid;
SELECT SUBTOTAL into Subtotal FROM Comprobante where current_id = customertrxid;
SELECT sum(IMPORTE) into SumaTasa03 FROM Traslados where TasaOcuota = '0.030000' and current_id = customertrxid;
SELECT IMPORTE into ImporteTotal03 FROM TrasladosTotal where TasaOcuota = '0.030000' and current_id = customertrxid;
SELECT sum(IMPORTE) into SumaTasa16 FROM Traslados where TasaOcuota = '0.160000' and current_id = customertrxid;
SELECT IMPORTE into ImporteTotal16 FROM TrasladosTotal where TasaOcuota = '0.160000' and current_id = customertrxid;
SELECT sum(IMPORTE) into SumaImpuesto FROM TrasladosTotal where current_id = customertrxid;
SELECT TOTALIMPUESTOSTRASLADOS into ImpuestoTotal FROM ImpuestosTotal where current_id = customertrxid;
dbms_output.put_line('Suma importe conceptos ' || SumaImporteCon);
dbms_output.put_line('Subtotal Comprobante: ' || Subtotal);
IF (SumaImporteCon = Subtotal) THEN
dbms_output.put_line('SI coinciden');
ELSE
dbms_output.put_line('NO coinciden');
END IF;
dbms_output.put_line('Suma tasa 0.03: ' || SumaTasa03);
dbms_output.put_line('Importe 0.03: ' || ImporteTotal03);
IF ( SumaTasa03 = ImporteTotal03) THEN
dbms_output.put_line('SI coinciden');
ELSE
dbms_output.put_line('NO coinciden');
END IF;
dbms_output.put_line('Suma tasa 0.16: ' || SumaTasa16);
dbms_output.put_line('Importe 0.16: ' || ImporteTotal16);
IF (SumaTasa16 = ImporteTotal16) THEN
dbms_output.put_line('SI coinciden');
ELSE
dbms_output.put_line('NO coinciden');
END IF;
dbms_output.put_line('Suma importe impuesto: ' || SumaImpuesto);
dbms_output.put_line('El impuesto total: ' || ImpuestoTotal);
IF (SumaImpuesto = ImpuestoTotal) THEN
dbms_output.put_line('SI coinciden');
ELSE
dbms_output.put_line('NO coinciden');
END IF;
END LOOP;
END;
/
/
1条答案
按热度按时间oknrviil1#
在循环中使用
OUTER JOIN
s。类似于(未经测试,但它给了你大致的概念):