{"id":76047,"date":"2024-05-12T17:26:06","date_gmt":"2024-05-12T21:26:06","guid":{"rendered":"http:\/\/bangla.sitestree.com\/?p=76047"},"modified":"2024-05-12T17:26:06","modified_gmt":"2024-05-12T21:26:06","slug":"oracle-pl-sql-if-then-else-for-loop-while-loop","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=76047","title":{"rendered":"Oracle PL\/SQL: If-Then-Else, For Loop, While Loop"},"content":{"rendered":"<p>How it works: if, elsif, else (then) (Click on the images to see them clearly)<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2024\/05\/image-22.png\" rel=\"attachment wp-att-76048\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2024\/05\/image-22.png?resize=750%2C750\" alt=\"\" title=\"image-22-png\" width=\"750\" height=\"750\" class=\"alignnone size-full wp-image-76048\" \/><\/a><\/p>\n<p>Ref: <a href=\"https:\/\/docs.oracle.com\/cd\/B13789_01\/appdev.101\/b10807\/13_elems024.htm\">https:\/\/docs.oracle.com\/cd\/B13789_01\/appdev.101\/b10807\/13_elems024.htm<\/a><\/p>\n<p>Example:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2024\/05\/image-23.png\" rel=\"attachment wp-att-76049\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2024\/05\/image-23.png?resize=750%2C750\" alt=\"\" title=\"image-23-png\" width=\"750\" height=\"750\" class=\"alignnone size-full wp-image-76049\" \/><\/a><\/p>\n<p>Ref: <a href=\"https:\/\/docs.oracle.com\/cd\/B13789_01\/appdev.101\/b10807\/13_elems024.htm\">https:\/\/docs.oracle.com\/cd\/B13789_01\/appdev.101\/b10807\/13_elems024.htm<\/a><\/p>\n<p><strong>Oracle: CASE, WHEN, THEN<\/strong><br \/>\n<a href=\"\" rel=\"attachment wp-att-76050\"><img loading=\"lazy\" decoding=\"async\" src=\"\" alt=\"\" title=\"image-24-png\" width=\"1024\" height=\"1024\" class=\"alignnone size-full wp-image-76050\" \/><\/a><\/p>\n<p>Simple:<br \/>\n<a href=\"\" rel=\"attachment wp-att-76051\"><img loading=\"lazy\" decoding=\"async\" src=\"\" alt=\"\" title=\"image-25-png\" width=\"1024\" height=\"1024\" class=\"alignnone size-full wp-image-76051\" \/><\/a><\/p>\n<p>Searched:<br \/>\n<a href=\"\" rel=\"attachment wp-att-76052\"><img loading=\"lazy\" decoding=\"async\" src=\"\" alt=\"\" title=\"image-26-png\" width=\"1024\" height=\"1024\" class=\"alignnone size-full wp-image-76052\" \/><\/a>&#8221;<br \/>\nElse:<br \/>\n<a href=\"\" rel=\"attachment wp-att-76053\"><img loading=\"lazy\" decoding=\"async\" src=\"\" alt=\"\" title=\"image-27-png\" width=\"1024\" height=\"1024\" class=\"alignnone size-full wp-image-76053\" \/><\/a><\/p>\n<p><strong>Reverse For Loop<\/strong><\/p>\n<p><a href=\"https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2024\/05\/image-28.png\" rel=\"attachment wp-att-76054\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2024\/05\/image-28.png?resize=750%2C750\" alt=\"\" title=\"image-28-png\" width=\"750\" height=\"750\" class=\"alignnone size-full wp-image-76054\" \/><\/a><\/p>\n<p>Ref: For Loop Examples in Oracle<\/p>\n<p><a href=\"https:\/\/docs.oracle.com\/cd\/E11882_01\/appdev.112\/e25519\/controlstatements.htm#BABEFFDC\">https:\/\/docs.oracle.com\/cd\/E11882_01\/appdev.112\/e25519\/controlstatements.htm#BABEFFDC<\/a><\/p>\n<p><strong>Oracle While Loop<\/strong><\/p>\n<p><a href=\"\" rel=\"attachment wp-att-76055\"><img loading=\"lazy\" decoding=\"async\" src=\"\" alt=\"\" title=\"image-29-png\" width=\"1024\" height=\"1024\" class=\"alignnone size-full wp-image-76055\" \/><\/a><\/p>\n<p><strong>While loop example from the referenced url<\/strong><\/p>\n<p>DECLARE<br \/>\ndone BOOLEAN := FALSE;<br \/>\nBEGIN<br \/>\nWHILE done LOOP<br \/>\nDBMS_OUTPUT.PUT_LINE (&#8216;This line does not print.&#8217;);<br \/>\ndone := TRUE; &#8212; This assignment is not made.<br \/>\nEND LOOP;<\/p>\n<p>WHILE NOT done LOOP<br \/>\nDBMS_OUTPUT.PUT_LINE (&#8216;Hello, world!&#8217;);<br \/>\ndone := TRUE;<br \/>\nEND LOOP;<br \/>\nEND;<br \/>\n\/<\/p>\n<p>Ref: <a href=\"https:\/\/docs.oracle.com\/en\/database\/oracle\/oracle-database\/19\/lnpls\/plsql-control-statements.html#GUID-3F69F563-BCAE-4D3E-8E03-F53C8D64D093\">https:\/\/docs.oracle.com\/en\/database\/oracle\/oracle-database\/19\/lnpls\/plsql-control-statements.html#GUID-3F69F563-BCAE-4D3E-8E03-F53C8D64D093<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How it works: if, elsif, else (then) (Click on the images to see them clearly) Ref: https:\/\/docs.oracle.com\/cd\/B13789_01\/appdev.101\/b10807\/13_elems024.htm Example: Ref: https:\/\/docs.oracle.com\/cd\/B13789_01\/appdev.101\/b10807\/13_elems024.htm Oracle: CASE, WHEN, THEN Simple: Searched: &#8221; Else: Reverse For Loop Ref: For Loop Examples in Oracle https:\/\/docs.oracle.com\/cd\/E11882_01\/appdev.112\/e25519\/controlstatements.htm#BABEFFDC Oracle While Loop While loop example from the referenced url DECLARE done BOOLEAN := FALSE; BEGIN WHILE &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=76047\">Continue reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[182],"tags":[],"class_list":["post-76047","post","type-post","status-publish","format-standard","hentry","category---blog","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":76038,"url":"http:\/\/bangla.sitestree.com\/?p=76038","url_meta":{"origin":76047,"position":0},"title":"Misc. Oracle: Data Types: Why a Data Type.","author":"Sayed","date":"May 12, 2024","format":false,"excerpt":"Ref: https:\/\/docs.oracle.com\/cd\/B13789_01\/appdev.101\/b10807\/02_funds.htm https:\/\/stackoverflow.com\/questions\/7425153\/reason-why-oracle-is-case-sensitive Oracle Data Types and Allowed Sizes: https:\/\/docs.oracle.com\/cd\/E11882_01\/appdev.112\/e25519\/datatypes.htm#LNPLS99943 Oracle SIMPLE_FLOAT vs SIMPLE_DOUBLE Ref: https:\/\/docs.oracle.com\/cd\/B28359_01\/appdev.111\/b28370\/datatypes.htm#CJAEAEJG PLS_Integer vs Number \"The PLS_INTEGER data type has these advantages over the NUMBER data type and NUMBER subtypes: PLS_INTEGER values require less storage. PLS_INTEGER operations use hardware arithmetic, so they are faster than NUMBER\u2026","rel":"","context":"In &quot;\u09ac\u09cd\u09b2\u0997 \u0964 Blog&quot;","block_context":{"text":"\u09ac\u09cd\u09b2\u0997 \u0964 Blog","link":"http:\/\/bangla.sitestree.com\/?cat=182"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2024\/05\/image-19.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2024\/05\/image-19.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2024\/05\/image-19.png?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2024\/05\/image-19.png?resize=700%2C400 2x, https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2024\/05\/image-19.png?resize=1050%2C600 3x"},"classes":[]},{"id":76598,"url":"http:\/\/bangla.sitestree.com\/?p=76598","url_meta":{"origin":76047,"position":1},"title":"What is a Dynamic Cursor in Oracle PL\/SQL","author":"Sayed","date":"January 29, 2025","format":false,"excerpt":"Dynamic\/Ref Cursor CREATE OR REPLACE PROCEDURE query_invoice( month VARCHAR2, year VARCHAR2) IS TYPE cur_typ IS REF CURSOR; c cur_typ; query_str VARCHAR2(200); inv_num NUMBER; inv_cust VARCHAR2(20); inv_amt NUMBER;BEGIN query_str := 'SELECT num, cust, amt FROM inv_' || month ||'_'|| year || ' WHERE invnum = :id'; OPEN c FOR query_str USING\u2026","rel":"","context":"In &quot;Root&quot;","block_context":{"text":"Root","link":"http:\/\/bangla.sitestree.com\/?cat=1"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2025\/01\/image-20.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":76044,"url":"http:\/\/bangla.sitestree.com\/?p=76044","url_meta":{"origin":76047,"position":2},"title":"Oracle Sub Types for Data Types: Exception Block","author":"Sayed","date":"May 12, 2024","format":false,"excerpt":"An unconstrained subtype has the same set of values as its base type, so it is only another name for the base type. Syntax: SUBTYPE subtype_name IS base_type Example: SUBTYPE \"DOUBLE PRECISION\" IS FLOAT SUBTYPE Balance IS NUMBER; Constrained SubType SUBTYPE Balance IS NUMBER(8,2); Oracle Exception Block Example: Ref: https:\/\/docs.oracle.com\/cd\/B13789_01\/appdev.101\/b10807\/07_errs.htm","rel":"","context":"In &quot;\u09ac\u09cd\u09b2\u0997 \u0964 Blog&quot;","block_context":{"text":"\u09ac\u09cd\u09b2\u0997 \u0964 Blog","link":"http:\/\/bangla.sitestree.com\/?cat=182"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":76035,"url":"http:\/\/bangla.sitestree.com\/?p=76035","url_meta":{"origin":76047,"position":3},"title":"Oracle Data types, ROWID, PLS_INTEGER vs INTEGER","author":"Sayed","date":"May 12, 2024","format":false,"excerpt":"Data Types Ref: https:\/\/docs.oracle.com\/cd\/A97630_01\/server.920\/a96524\/c13datyp.htm (Click on the image to see it properly) Why PLS_Integer: https:\/\/docs.oracle.com\/cd\/B13789_01\/appdev.101\/b10807\/03_types.htm \u201cYou use the PLS_INTEGER datatype to store signed integers. Its magnitude range is -231 .. 231. PLS_INTEGER values require less storage than NUMBER values. Also, PLS_INTEGER operations use machine arithmetic, so they are faster than\u2026","rel":"","context":"In &quot;\u09ac\u09cd\u09b2\u0997 \u0964 Blog&quot;","block_context":{"text":"\u09ac\u09cd\u09b2\u0997 \u0964 Blog","link":"http:\/\/bangla.sitestree.com\/?cat=182"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2024\/05\/image-16.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2024\/05\/image-16.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2024\/05\/image-16.png?resize=525%2C300 1.5x"},"classes":[]},{"id":76101,"url":"http:\/\/bangla.sitestree.com\/?p=76101","url_meta":{"origin":76047,"position":4},"title":"Oracle Trigger","author":"Sayed","date":"May 20, 2024","format":false,"excerpt":"Click on the images to see them clearly Example: Ref: https:\/\/docs.oracle.com\/cd\/B13789_01\/server.101\/b10759\/statements_7004.htm","rel":"","context":"In &quot;\u09ac\u09cd\u09b2\u0997 \u0964 Blog&quot;","block_context":{"text":"\u09ac\u09cd\u09b2\u0997 \u0964 Blog","link":"http:\/\/bangla.sitestree.com\/?cat=182"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2024\/05\/image-52.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2024\/05\/image-52.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2024\/05\/image-52.png?resize=525%2C300 1.5x"},"classes":[]},{"id":75826,"url":"http:\/\/bangla.sitestree.com\/?p=75826","url_meta":{"origin":76047,"position":5},"title":"Some Topics to Know and Understand to prepare for a DBMS related Job Interview","author":"Sayed","date":"June 25, 2023","format":false,"excerpt":"Some Topics to Know and Understand to prepare for a DBMS related Job Interview ACID ACID: https:\/\/www.geeksforgeeks.org\/acid-properties-in-dbms Database Normalization 1NF: No repeating groups possible for a cell, PK identified, dependencies mapped 2NF: No Partial Dependence. Non key attributes must have to depend on the full key 3NF: No transitive dependency.\u2026","rel":"","context":"In &quot;\u09ac\u09cd\u09b2\u0997 \u0964 Blog&quot;","block_context":{"text":"\u09ac\u09cd\u09b2\u0997 \u0964 Blog","link":"http:\/\/bangla.sitestree.com\/?cat=182"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/76047","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=76047"}],"version-history":[{"count":1,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/76047\/revisions"}],"predecessor-version":[{"id":76056,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/76047\/revisions\/76056"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=76047"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=76047"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=76047"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}