内部查询返回多行

时间:2015-07-14 08:25:32

标签: sql oracle

SELECT 
    FORM_OF_PAYMENT_CD paymentMethod,   
    DECODE (CC_TYPE_CD, 'V', 'VS', 'M', 'MC', 'A', 'AM', 'D', 'DC', NULL) paymentSubMethod,
    PAYMENT_AMOUNT amount,
    LPAD(SUBSTR(trim(PCI_PKG.D_CC(op.CC_NUMBER, 654916320742196284)),
    LENGTH(trim(PCI_PKG.D_CC(op.CC_NUMBER, 654916320742196284)))-3),
    LENGTH(trim(PCI_PKG.D_CC(op.CC_NUMBER, 654916320742196284))) , '*') ccNumber,
    CC_EXP_DATE ccExpirationDate,
    IAI.ADDRESS addressLine1,
    IAI.ZIP zipCode,
    IAI.ZIP_EXTENSION zip4Code,
    DECODE(ORM.EPP_CHANNEL_ID, NULL, NULL, (ORM.EPP_CHANNEL_ID ||'^'   || ORM.EPP_ACTOR_ID   ||'^'   || OP.EPP_TOKEN_ID   ||'^'   || OP.EPP_TOKEN_TYPE   ||'^'   ||       (
        SELECT DISTINCT AUTH.EPP_PAYMENT_ID
        FROM OEMADM.AUTHORIZATION_INFO AUTH
        WHERE AUTH.ORDER_KEY= OP.ORDER_KEY   )) ) eppPaymentInfo,
    (SELECT AI.AUTH_CODE
     FROM AUTHORIZATION_INFO AI
     WHERE AI.PAYMENT_TYPE_CD = op.PAYMENT_TYPE_CD
       AND AI.ORDER_KEY = op.ORDER_KEY
       AND AI.AUTH_TYPE_CD = 'PRE' ) AUTHORIZATION_CODE,
    (SELECT AI.AUTH_STATUS_DESC
     FROM AUTHORIZATION_INFO AI
     WHERE AI.PAYMENT_TYPE_CD = op.PAYMENT_TYPE_CD  
       AND AI.ORDER_KEY = op.ORDER_KEY
       AND AI.AUTH_TYPE_CD = 'PRE' ) PRE_AUTHORIZATION_MSG,
    (SELECT UPDATED_DT   
     FROM SETTLEMENT_REFUND_RESP   
     WHERE TRANSACTION_TYPE_CODE = 'SET'   
       AND PAYMENT_TYPE_CD ='DQP'   
       AND ORDER_KEY = OP.ORDER_KEY   ) REQUEST_DATE ,
    OP.PAYMENT_TYPE_CD paymentTypeCode 
FROM 
    OEMADM.ORDER_PAYMENTS OP,   
    OEMADM.IDENT_ADDRESS_INFO IAI,   
    OEMADM.ORDER_MASTER ORM 
WHERE 
    OP.ORDER_KEY           = 'ow-srso-229451126' 
AND ORM.ORDER_KEY          = OP.ORDER_KEY 
AND IAI.IDENT_ADDR_INFO_ID = OP.PAYER_ADDR_INFO_ID

以上查询未执行,因为

  

内部查询返回多行。

1 个答案:

答案 0 :(得分:0)

分别运行以下子查询以查看哪一个基于您可能需要使用DISTINCT(或分组依据)返回多行,或者在where子句中添加另一个条件,使其唯一(取决于您的数据)。如果子查询返回多行,则无法作为完整查询运行。

 (SELECT AI.AUTH_CODE FROM AUTHORIZATION_INFO AI WHERE AI.PAYMENT_TYPE_CD = op.PAYMENT_TYPE_CD AND AI.ORDER_KEY = op.ORDER_KEY AND AI.AUTH_TYPE_CD = 'PRE' ) 

 (SELECT AI.AUTH_STATUS_DESC FROM AUTHORIZATION_INFO AI WHERE AI.PAYMENT_TYPE_CD = op.PAYMENT_TYPE_CD AND AI.ORDER_KEY = op.ORDER_KEY AND AI.AUTH_TYPE_CD = 'PRE' ) 

 (SELECT UPDATED_DT FROM SETTLEMENT_REFUND_RESP WHERE TRANSACTION_TYPE_CODE = 'SET' AND PAYMENT_TYPE_CD ='DQP' AND ORDER_KEY = OP.ORDER_KEY ) REQUEST_DATE ,