How To Write PL/SQL block using Loop Statement & Exception Handling.

INPUT
declare
          no number(5);
          bal number(6);
          deb_bal number(6);
          min_bal constant number(5):=500;

begin
          no:=&no;
          deb_bal:=&deb_bal;
          select balance into bal from acc where acc_no=no;
          if bal>min_bal then
                   update acc set balance=balance-deb_bal where acc_no=no;
                   dbms_output.put_line('debit sucessfully');
          else
                   dbms_output.put_line('you have not minimum balance');
          end if;

end;

OUTPUT
1)
Enter value for no: 1201
old   8:  no:=&no;
new   8:  no:=1201;
Enter value for deb_bal: 1000
old   9:  deb_bal:=&deb_bal;
new   9:  deb_bal:=1000;
debit sucessfully
PL/SQL procedure successfully completed.


2)
Enter value for no: 1202
old   8:  no:=&no;
new   8:  no:=1202;
Enter value for deb_bal: 100
old   9:  deb_bal:=&deb_bal;
new   9:  deb_bal:=100;
you have not minimum balance
PL/SQL procedure successfully completed.

Post a Comment

3 Comments

  1. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.

    oracle training in bangalore


    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Very clear explanation here. For anyone looking to turn this knowledge into real career skills, IMMEK Softech
    provides excellent AWS and DevOps courses with industry-focused guidance.
    to be a great choice for AWS and DevOps – quality teaching and practical exposure
    aws-with-devops-training-in-chennai
    AWS Training in Chennai
    google-cloud-training-bi
    azure-training-in-chennai

    ReplyDelete