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 / bijaylaxmi

create or replace procedure proc_bal (paccno srabank.accno%type)
is
pbal srabank.bal%type;
pacctype srabank.acctype%type;
pamt number:=2000;
begin
select bal,acctype into pbal,pacctype from srabank where accno=paccno;
if pacctype= 'rd' and pbal>0
then pbal:=pbal+pamt;

elsif pacctype= 's' and pbal>0
then pbal:=pbal-pamt;
elsif pacctype= 'c' and pbal>0
then pbal:=pbal*pamt;
end if;
dbms_output.put_line( pbal);
insert into srabank_tran values (pbal,paccno);
insert into srabank_det select amt,accno from srabank_tran;
end proc_bal;

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does executeupdate return?

929


How to change server name in sql server?

1100


How to replace the Query Result 'Null Value' with a text ?

974


Is port 1433 secure?

932


Describe in brief authentication modes in sql server.

968


How can i Relate Tables in SSIS

1036


What is the chart in report?

144


Can you explain what are various ways to enhance the ssrs report?

957


What is function of master database?

114


How do you start single user mode in clustered installations?

905


Explain Normalization and DE normalization

1055


Explain the flow of creating a cube? : sql server analysis services, ssas

1005


What is the optimization being performed in oracle and SQL Server?

999


What is difference between cte and view?

858


What are the advantages of the mirroring?

1015