Forum

Write a PL/SQL Proc...
 
Share:
Notifications
Clear all

Write a PL/SQL Procedure to Perform a Withdrawal operation that only permits a withdrawal, if there are sufficient funds in the account then update the Account table and print the message


Posts: 1
Guest
Topic starter
(@Rahul U)
New Member
Joined: 4 years ago

Write a PL/SQL procedure to perform a withdrawal operation that only permits a withdrawal, if there are sufficient funds in the account then update the Account table and print the message, 'Transaction successful.' else print, 'Insufficient Amount'.

Please check the attachment for additional information.

2 Replies
Posts: 47
Guest
(@Sambit S)
Eminent Member
Joined: 4 years ago

You can try the below procedure. 

Create or replace procedure
withdraw(acno number, amt number)
Is
V_amt number:=0;
Begin
Select Balance into v_amt
From account
Where accno = acno;

If amt < v_amt then

Update account
Set balance = balance -amt
Where accno = acno;
Commit;

dbms_output.put_line('Transaction Successful');

Else
dbms_output.put_line('Insufficient balance');

End if;

Exception
When others then
Rollback;

End;

Reply
1 Reply
(@rahul)
Joined: 4 years ago

Active Member
Posts: 17

@Sambit S only 1 test case is passed

Reply

Self Learning Video Tutorials - Software Course

Leave a reply

Author Name

Author Email

Title *

 
Preview 0 Revisions Saved
Share: