CASE statement advice needed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shivani Johri
    New Member
    • Jun 2007
    • 1

    CASE statement advice needed

    It appears that this query goes into an endless loop. Can someone please identify the error? The 4 tables referenced (CPADF_DT , CPACCDEF , CPARTY, CPDELACC) have less that 2000 records each.

    --CP BANK ACCOUNT DEFAULTS
    SELECT
    CPARTY.NAME AS "COUNTERPAR TY" ,
    CPACCDEF.TRANS_ TYPE AS "TRANSACTIO N TYPE",
    CPACCDEF.SECTYP E AS "INSTRUMENT TYPE",
    CPACCDEF.ENTITY AS "ENTITY",
    CPACCDEF.FACILI TY AS "RELATIONSH IP",
    CPACCDEF.CFLOW_ TYPE AS "CASHFLOW TYPE",
    CPACCDEF.CCY AS "CURRENCY",
    CASE CPACCDEF.PAY_RE C
    WHEN 'B' THEN 'BOTH'
    WHEN 'P' THEN 'PAYMENTS'
    WHEN 'R' THEN 'RECEIPTS'
    ELSE
    CPACCDEF.PAY_RE C END AS "PAYMENTS/RECEIPTS",
    CPADF_DT.EFFECT _DT AS "EFFECTIVE DATE",
    CPADF_DT.ACC_NO AS "ACCOUNT NUMBER / IDENTIFIER",
    CPDELACC.ACC_NA ME AS "ACCOUNT NAME/PAYMENT METHOD", CPDELACC.CCY AS "CURRENCY",
    CPDELACC.BANK_N AME AS "BANK NAME"
    FROM CPADF_DT , CPACCDEF , CPARTY, CPDELACC
  • siva538
    New Member
    • Jun 2007
    • 44

    #2
    Hey first of all the join happening here is cross join and hence it will result in the cartesian product of all the 4 tables and I don't think it is the intended behavior.

    there should be some joining condition between the tables.

    finally it is recommended to use aliases for the tables in the join so that query looks good :)

    Comment

    • BHARATH RS
      New Member
      • May 2007
      • 6

      #3
      Hi,

      I think its not going into an endless loop. The thing is that, since no join condition is provided it will be a cartesian product and if there are lot of rows in each of the tables it will take a lot of time to execute the above query.

      The solution to ur problem is that have join conditions so that you filter out unwanted rows.

      Comment

      Working...