Friday, February 4, 2011

Bank details finding query

Validation to check whether the given bank already exists
SELECT                COUNT(*)
FROM                    (SELECT               aba.bank_account_name,
                                                                aba.bank_account_num,
                                                                aba.currency_code,
                                                                abb.bank_name,
                                                                abb.bank_branch_name,
                                                                abb.bank_num,
                                                                --abb.bank_number
                                                                abb.country         
                                FROM                    ap_bank_accounts aba,
                                                                ap_bank_branches abb
                                WHERE                abb.bank_branch_id = aba.bank_branch_id                ) BANK
WHERE                                bank_account_num  = NVL(cur_cust_bnk.bank_account_num,bank_account_num)
AND                       bank_account_name = NVL(cur_cust_bnk.bank_account_name,bank_account_name)
AND                       bank_name            = NVL(cur_cust_bnk.bank_name,bank_name)
AND                       bank_num          = NVL(cur_cust_bnk.bank_num,bank_num)
--AND                    NVL(bank_number,1)= NVL(NVL(cur_cust_bnk.bank_number,bank_number),1)
AND                       bank_branch_name  = NVL(cur_cust_bnk.bank_branch_name,bank_branch_name)
AND                       currency_code       = NVL(cur_cust_bnk.bank_account_currency_code,currency_code)
AND                       country                    = NVL(cur_cust_bnk.bank_branch_country,country);

No comments:

Post a Comment