The problem is that in the following statement
select external_users.external_user_id into user_id_temp
from external_users
join financial_accounts
using (external_user_id)
join payments
on financial_accounts.account_number = payments.sending_account_number
where financial_accounts.account_number = payments.sending_account_number;
the USING
clause merges EXTERNAL_USERS.EXTERNAL_USER_ID
and FINANCIAL_ACCOUNTS.EXTERNAL_USER_ID
into a single EXTERNAL_USER_ID
field, and thus you can no longer say EXTERNAL_USERS.EXTERNAL_USER_ID
. Change the statement to
select external_user_id
into user_id_temp
from external_users
join financial_accounts
using (external_user_id)
join payments
on financial_accounts.account_number = payments.sending_account_number
where financial_accounts.account_number = payments.sending_account_number;
and give it a try.
Share and enjoy.