{"id":139,"date":"2026-03-21T04:14:46","date_gmt":"2026-03-21T04:14:46","guid":{"rendered":"https:\/\/alpeshconnect.in\/blog\/?p=139"},"modified":"2026-03-21T04:14:46","modified_gmt":"2026-03-21T04:14:46","slug":"pl-sql-bank-balance","status":"publish","type":"post","link":"https:\/\/alpeshconnect.in\/blog\/2026\/03\/21\/pl-sql-bank-balance\/","title":{"rendered":"Pl Sql Bank Balance"},"content":{"rendered":"\n<p>Pl\/SQL block to withdraw a specified amount from a bank account, updating the balance. if the new balance after the withdrawal goes below 5000, raise an error.<\/p>\n\n\n\n<p>&#8212; Enable DBMS output<br>SET SERVEROUTPUT ON;<\/p>\n\n\n\n<p>DECLARE<br>v_balance NUMBER := 10000; &#8212; Initial balance (example)<br>v_withdraw NUMBER;<br>min_balance CONSTANT NUMBER := 5000;<br>BEGIN<br>&#8212; Accept user input<br>v_withdraw := &amp;enter_amount;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>-- Display input\nDBMS_OUTPUT.PUT_LINE('Withdrawal Amount: ' || v_withdraw);\n\n-- Check balance condition\nIF (v_balance - v_withdraw) &lt; min_balance THEN\n    RAISE_APPLICATION_ERROR(-20001, 'Error: Minimum balance of 5000 must be maintained!');\nELSE\n    v_balance := v_balance - v_withdraw;\n    DBMS_OUTPUT.PUT_LINE('Withdrawal successful.');\n    DBMS_OUTPUT.PUT_LINE('Remaining Balance: ' || v_balance);\nEND IF;<\/code><\/pre>\n\n\n\n<p>EXCEPTION<br>WHEN OTHERS THEN<br>DBMS_OUTPUT.PUT_LINE(SQLERRM);<br>END;<br>\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pl\/SQL block to withdraw a specified amount from a bank account, updating the balance. if the new balance after the withdrawal goes below 5000, raise an error. &#8212; Enable DBMS outputSET SERVEROUTPUT ON; DECLAREv_balance NUMBER := 10000; &#8212; Initial balance (example)v_withdraw NUMBER;min_balance CONSTANT NUMBER := 5000;BEGIN&#8212; Accept user inputv_withdraw := &amp;enter_amount; EXCEPTIONWHEN OTHERS THENDBMS_OUTPUT.PUT_LINE(SQLERRM);END;\/<\/p>\n","protected":false},"author":1,"featured_media":101,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,42],"tags":[25,26,43],"class_list":["post-139","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bca","category-concept-of-rdbms","tag-bca","tag-bca-paper-solution","tag-concept-of-rdbms"],"_links":{"self":[{"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/posts\/139","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/comments?post=139"}],"version-history":[{"count":1,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/posts\/139\/revisions"}],"predecessor-version":[{"id":140,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/posts\/139\/revisions\/140"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/media\/101"}],"wp:attachment":[{"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/media?parent=139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/categories?post=139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/tags?post=139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}