I have two tables.account on server and account1 on site , which have same attributes but different data.
CREATE TABLE ACCOUNT (
Accno int,
Balance int,
Acctype varchar2(20),
Accbranch varchar2(20),
PRIMARY KEY(Accno));
CREATE TABLE ACCOUNT1 (
Accno int,
Balance int,
Acctype varchar2(20),
Accbranch varchar2(20),
PRIMARY KEY(Accno));
now i wish to make a procedure that will make withdrawal bank transaction.user will give input a account number which may from either account table or account1 table and the withdrawal amount. then the procedure will update the balance in that specific table which has the account number that user has given as input. My code is ok for one table.but cant understand what to do for two horizontally fragmented table(account and account1). Can anyone suggest me a better way to find the solution. here is my procedure
CREATE OR REPLACE PROCEDURE test(x IN number, y IN number)
AS
cur_balance number;
new_balance number;
BEGIN
select Balance into cur_balance
from Account
where Accno = x;
if (cur_balance < y)then
dbms_output.put_line('Insufficient balance');
else
new_balance:=cur_balance-y;
update Account
set Balance = new_balance
where Accno = x;
end if;
dbms_output.put_line('Money has been withdrawn successfully');
dbms_output.put_line('Current Balance:' || new_balance);
commit;
END;
/