{"id":10830,"date":"2019-07-30T12:01:53","date_gmt":"2019-07-30T12:01:53","guid":{"rendered":"https:\/\/ittutorial.org\/?p=10830"},"modified":"2019-07-30T12:02:18","modified_gmt":"2019-07-30T12:02:18","slug":"pl-sql-programing-5-if-else-condition","status":"publish","type":"post","link":"https:\/\/ittutorial.org\/pl-sql-programing-5-if-else-condition\/","title":{"rendered":"PL\/SQL Programing -5 IF-ELSE Condition"},"content":{"rendered":"<p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">Hi all in this article we continue with the flow operators in PL \/ SQL Programming<\/span><\/span>. <span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">You can browse our previous article before moving on to this article<\/span><\/span><\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"gp5j7kcPxQ\"><p><a href=\"https:\/\/ittutorial.org\/pl-sql-programing-4-characters-and-data-types\/\">PL\/SQL Programing -4  Characters and Data types<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;PL\/SQL Programing -4  Characters and Data types&#8221; &#8212; IT Tutorial\" src=\"https:\/\/ittutorial.org\/pl-sql-programing-4-characters-and-data-types\/embed\/#?secret=Ux9KdiFRlv#?secret=gp5j7kcPxQ\" data-secret=\"gp5j7kcPxQ\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p>&nbsp;<\/p>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">Structures like IF-ELSE in PL \/ SQL are similar to many programming languages.<\/span><\/span> <span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">In its simplest form, TRUE results in the return of FALSE in an undesirable or different result if a condition is desired in a desired state.<\/span><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8609\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/04\/if_else_statement-235x300.jpg\" alt=\"\" width=\"519\" height=\"663\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/04\/if_else_statement-235x300.jpg 235w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/04\/if_else_statement.jpg 251w\" sizes=\"auto, (max-width: 519px) 100vw, 519px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3>IF-THEN YAPISI:<\/h3>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span title=\"\">Basically there is the IF-THEN syntax with the condition and the block of code that will then run.<\/span> <span class=\"\" title=\"\">IF-THEN structure is closed with END-IF block after code execution<\/span><\/span>.<\/p>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span title=\"\">IF THEN condition<\/span><\/p>\n<p><span title=\"\">PL \/ SQL Code;<\/span><\/p>\n<p><span title=\"\">&#8230;&#8230;..<\/span><\/p>\n<p><span title=\"\">&#8230;&#8230;.<\/span><\/p>\n<p><span class=\"\" title=\"\">END IF;<\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<pre>SQL&gt;set serveroutput on;\r\n\r\nDECLARE\r\n\r\nsayi1 NUMBER:=5;\r\n\r\nsayi2 NUMBER:=2;\r\n\r\nfark NUMBER;\r\n\r\nBEGIN\r\n\r\nIF sayi1&gt;sayi2 THEN\r\n\r\nfark:=sayi1-sayi2;\r\n\r\nEND IF;\r\n\r\nDBMS_OUPUT.PUT_LINE('SAYI1 = '||sayi1);\r\n\r\nDBMS_OUPUT.PUT_LINE('SAYI2 = '||sayi2);\r\n\r\nDBMS_OUPUT.PUT_LINE('FARK = '||fark);\r\n\r\nEND;\r\n\/\r\n\r\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8610\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/04\/Screenshot_20-1-300x294.png\" alt=\"\" width=\"447\" height=\"438\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/04\/Screenshot_20-1-300x294.png 300w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/04\/Screenshot_20-1.png 430w\" sizes=\"auto, (max-width: 447px) 100vw, 447px\" \/>\r\n\r\n<\/pre>\n<h3>IF-THEN-ELSE:<\/h3>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span title=\"\">This structure contains the ELSE block in addition to the previous one.<\/span> <span title=\"\">IF-THEN is the block that contains the codes that will be executed when the condition is not met.<\/span> <span class=\"\" title=\"\">Explain through the example would be the most tutorial<\/span><\/span>.<\/p>\n<pre>DECLARE \r\nsayi1 NUMBER:=10; \r\nsayi2 NUMBER:=5; \r\nsonuc NUMBER: \r\nBEGIN \r\nIF sayi1&lt;sayi2 THEN \r\nsonuc:=sayi1+sayi2; \r\nELSE \r\nsonuc:=sayi1*sayi2; \r\nEND IF; \r\nDBMS_OUTPUT.PUT_LINE('Sonu\u00e7 : '||sonuc); \r\nEND; \r\n\/<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8611\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/04\/Screenshot_21-2-300x270.png\" alt=\"\" width=\"396\" height=\"356\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/04\/Screenshot_21-2-300x270.png 300w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/04\/Screenshot_21-2.png 436w\" sizes=\"auto, (max-width: 396px) 100vw, 396px\" \/><\/p>\n<h3>IF-THEN-ELSIF:<\/h3>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">It is also a block structure that works in a similar manner to the previous one, but can only be used if more than one possible situation is desired instead of a single ELSE structure.<\/span><\/span><\/p>\n<p>DECLARE<br \/>\nsayi1 NUMBER:=5;<br \/>\nsayi2 NUMBER:=4;<br \/>\nsayi3 NUMBER:=3;<br \/>\nsonuc NUMBER;<br \/>\nBEGIN<br \/>\nIF sayi1&lt;sayi2 THEN<br \/>\nsonuc:=sayi1+sayi2;<br \/>\nELSEIF sayi2&lt;sayi3 THEN<br \/>\nsonuc:=sayi2+sayi3;<br \/>\nELSEIF sayi3&lt;sayi2 THEN<br \/>\nsonuc:=sayi3*sayi3;<br \/>\nELSE sonuc:=0;<br \/>\nEND IF;<br \/>\nDBMS_OUTPUT.PUT_LINE(&#8216;Sonu\u00e7 = &#8216;||sonuc);<br \/>\nEND;<br \/>\n\/<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8613\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/04\/Screenshot_22-2-300x264.png\" alt=\"\" width=\"430\" height=\"378\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/04\/Screenshot_22-2-300x264.png 300w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/04\/Screenshot_22-2.png 548w\" sizes=\"auto, (max-width: 430px) 100vw, 430px\" \/><br \/>\n<span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">I tried to explain the examples in a very simple way, but complex queries such as IF-THEN etc. or DML, DDL operations can be done.<\/span><\/span> <span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">A table can be UPDATE if any condition is met, or a different INSERT can be entered if not provided.<\/span> <span class=\"\" title=\"\">It is possible to duplicate such examples.<\/span><\/span><\/p>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">Let&#8217;s leave this article here and the next article will be looking at the CASE-WHEN and nested IF-THEN structures, to discuss.<\/span><\/span><\/p>\n<pre><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Hi all in this article we continue with the flow operators in PL \/ SQL Programming. You can browse our previous article before moving on to this article PL\/SQL Programing -4 Characters and Data types &nbsp; Structures like IF-ELSE in PL \/ SQL are similar to many programming languages. In its simplest form, TRUE results &hellip;<\/p>\n","protected":false},"author":67,"featured_media":10628,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3647],"tags":[3930,3664,3626,3928,3931,3630,3658,3923,3632,5629,3929,5628,3927,5625,5626,3932,5630,3925,3709,5623,5627,3926,3720,3718,3921,3922,3924,5624,3710,5622,3933,1572,3719],"class_list":["post-10830","post","type-post","status-publish","format-standard","has-post-thumbnail","","category-pl-sql","tag-basit-plsql","tag-bastan-sona-pl-sql","tag-declare-begin-end","tag-pl-sql-case-when","tag-pl-sql-degiskenler","tag-pl-sql-dersleri","tag-pl-sql-document","tag-pl-sql-lesson","tag-pl-sql-nedir","tag-plsql-administration","tag-plsql-baslangic-dersleri","tag-plsql-case-when","tag-plsql-case-yapisi","tag-plsql-cursor","tag-plsql-declare-begin-end","tag-plsql-degisken-atama","tag-plsql-developer","tag-plsql-donguler","tag-plsql-fonksiyonlar","tag-plsql-function","tag-plsql-if-clouse","tag-plsql-if-else","tag-plsql-kitaplari","tag-plsql-kurallari","tag-plsql-learning","tag-plsql-lessons","tag-plsql-ogrenmek","tag-plsql-procedure","tag-plsql-prosedur","tag-plsql-statement","tag-set-serveroputput-on","tag-sql","tag-sql-ve-plsql"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/07\/pl-sql.png","jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/10830","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/users\/67"}],"replies":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/comments?post=10830"}],"version-history":[{"count":1,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/10830\/revisions"}],"predecessor-version":[{"id":10831,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/10830\/revisions\/10831"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/media\/10628"}],"wp:attachment":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/media?parent=10830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/categories?post=10830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/tags?post=10830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}