can any one say how to update the following senario
I have a table <srabank>
in which the table structure is as follows
ANAME ACCNO LOCATION ACCTYPE BAL
SBanuPrakash 31518746291 Punganur deposit 4000
Sreenivas 31518746292 mahoobnagar current 14000
Ranjith 31518746293 Karimnagar Savings 2000
Giresh 31518746294 Chennai deposit 40000
Boo 31518746295 Chennai Savings 20000
Jay 31518746296 Valachari Savings 1000
tirumalraj 31518746297 Vellore Savings 8000
The senario is
We need to select one account number and check the balance after checking the balance if the balance exist we need to transfer to another account .
in the from account the amount need to be reduced and in the to account the amount needed to be added.
for example
for the <accountno> <31518746291> the balance is <4000>
for the <accno> <31518746292> the balance is <14000>
after transferring the balance the details will look as follows
<accno><31518746291> <bal> <2000>
<accno><31518746292> <bal> <16000>
the above mentioned two statment will come under the final result.
Answer Posted / akhil
the below program transfered the amount from one account to another account and generates the reference id and stores that reference id in the database;
in cus_det ac is the primary key
and in tranction table acc is the foreign key
then only reference number will be updated in the tranction table.
create or replace procedure test(acc1 in number,acc2 in number,amt in number) is
acm cus_det.am%type;
i number;
begin
select am into acm from cus_det where ac=acc1;
if acm<amt then
dbms_output.put_line('in sufficient funds');
else
update cus_det set am=am-amt where ac=acc1;
dbms_output.put_line('amount debited from senders account');
dbms_output.put_line('Tranction nnumber for your tranction....make a note of it for future reference');
select round(dbms_random.value(100000,200000)) into i from dual;
dbms_output.put_line(i);
update tranction set t_num=i where acc=acc1;
update cus_det set am=am+amt where ac=acc2;
dbms_output.put_line('amount credited to receivers account');
end if;
end;
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
how to determine the service pack currently installed on sql server? : Sql server database administration
Suppose you want to implement the following relationships while designing tables. How would you do it?a.) One-to-oneb.) One-to-manyc.) Many-to-many
what is the difference between Delete and Truncate command in SQL
Why I have to use stored procedures?
Explain system rowset functions?
What is indexing in sql server with example?
What is the difference between row_number and dense_rank?
What is the significance of null value and why should we avoid permitting null values?
How do you troubleshoot errors in a SQL Server Agent Job?
Where is my database stored on the hard disk in ms sql server?
How to provide column names in insert statements in ms sql server?
optimization techinques
What is conditional split?
Does a full backup include transaction log?
Explain unique key in sql server?