Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Hi, I am Akhil, I am also learing SQL, after reading your
question I have tried the pgm, please look into this.

And user need to give 2 accounts( from and to accounts )


create or replace procedure trans(acc1 in number, acc2 in
number,am in number) is
v_amount cus_details.amount%type;
begin
select amount into v_amount where acc_num=acc1;
if v_amount<am then
dbms_output.put_line('insufficient funds');
else
update cus_details set amount=amount-am where
acc_num=acc1;
dbms_output.put_line('amount debited from the
senders account');
update cus_details set amount=amount+am where
acc_num=acc2;
dbms_output.put_line('amount credited to the
receivers account');
end if;
end;


If any thing wrong, forgive me, thanks for making me to fee
about the task

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to change a login name in ms sql server?

1027


Recommend an approach to ensuring that all changes in the remote databases synchronize with the SQL Azure database?

128


How to verify a login name with sqlcmd tool?

1139


What does it mean to be in union?

873


What is the distinction amongst delete and truncate?

1003


How to get nth highest salary from employee table.

1105


Explain what is sql server english query?

988


What is the command used to check locks in microsoft sql server?

975


What is the syntax to execute the sys.dm_db_missing_index_details? : sql server database administration

1080


How to transfer a table from one schema to another?

940


but what if you have to create a database with two filegroups, one on drive c and the other on drive d with log on drive e with an initial size of 600 mb and with a growth factor of 15%? : Sql server database administration

922


How to get a list of columns using the "sp_help" stored procedure in ms sql server?

987


What is the datatype of rowid?

877


What is Cross Join and in which scenario do we use Cross Join?

977


What is key attribute?

873