{"id":3103,"date":"2018-05-20T23:56:00","date_gmt":"2018-05-20T14:56:00","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=3103"},"modified":"2023-04-27T23:45:41","modified_gmt":"2023-04-27T14:45:41","slug":"%e3%80%90pl-sql%e3%80%91%e6%9d%a1%e4%bb%b6%e5%88%86%e5%b2%90","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=3103","title":{"rendered":"\u3010PL\/SQL\u3011\u6761\u4ef6\u5206\u5c90"},"content":{"rendered":"<p>PL\/SQL\u3067\u306e\u6761\u4ef6\u5206\u5c90\u306e\u4ed5\u65b9\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<h2>\u666e\u901a\u306e\u6761\u4ef6\u5206\u5c90<\/h2>\n<h3>\u69cb\u6587<\/h3>\n<pre class=\"lang:default decode:true\">IF \u6761\u4ef6 THEN\r\n  \u51e6\u7406;\r\nEND IF;<\/pre>\n<h3>\u4f8b\u6587<\/h3>\n<pre class=\"lang:default decode:true\">DECLARE\r\n  num NUMBER := 2;\r\nBEGIN\r\n  IF num = 2 THEN\r\n  \tDBMS_OUTPUT.PUT_LINE('2\u306b\u4e00\u81f4\u3057\u3066\u3044\u307e\u3059\u3002');\r\n  END IF;\r\n\r\nEND;<\/pre>\n<h2>ELSE\u3092\u4f7f\u3046\u3002<\/h2>\n<h3>\u69cb\u6587<\/h3>\n<pre class=\"lang:default decode:true\">IF \u6761\u4ef6 THEN\r\n  \u51e6\u7406;\r\nELSE\r\n  \u51e6\u74062;\r\nEND IF;<\/pre>\n<h3>\u4f8b\u6587<\/h3>\n<pre class=\"lang:default decode:true\">DECLARE\r\n  num NUMBER := 2;\r\nBEGIN\r\n  IF num = 1 THEN\r\n  \tDBMS_OUTPUT.PUT_LINE('1\u306b\u4e00\u81f4\u3057\u3066\u3044\u307e\u3059\u3002');\r\n  ELSE\r\n  \tDBMS_OUTPUT.PUT_LINE('1\u306b\u4e00\u81f4\u3057\u3066\u3044\u307e\u305b\u3093\u3002');\r\n  END IF;\r\nEND;<\/pre>\n<h2>ELSEIF\u3092\u4f7f\u3046\u3002<\/h2>\n<h3>\u69cb\u6587<\/h3>\n<pre class=\"lang:default decode:true\">IF \u6761\u4ef6 THEN\r\n  \u51e6\u7406;\r\nELSEIF \u6761\u4ef62 THEN\r\n  \u51e6\u74062;\r\nELSE\r\n  \u51e6\u74063;\r\nEND IF;<\/pre>\n<h3>\u4f8b\u6587<\/h3>\n<pre class=\"lang:default decode:true\">DECLARE\r\n  num NUMBER := 2;\r\nBEGIN\r\n  IF num = 1 THEN\r\n  \tDBMS_OUTPUT.PUT_LINE('1\u306b\u4e00\u81f4\u3057\u3066\u3044\u307e\u3059\u3002');\r\n  ELSEIF num = 2 THEN\r\n  \tDBMS_OUTPUT.PUT_LINE('2\u306b\u4e00\u81f4\u3057\u3066\u3044\u307e\u3059\u3002');\r\n  ELSE\r\n  \tDBMS_OUTPUT.PUT_LINE('1\u306b\u30821\u306b\u3082\u306b\u4e00\u81f4\u3057\u3066\u3044\u307e\u305b\u3093\u3002');\r\n  END IF;\r\nEND;<\/pre>\n<h2>CASE\u6587\u3092\u4f7f\u3046\u3002<\/h2>\n<h3>\u69cb\u6587<\/h3>\n<pre class=\"lang:default decode:true\">CASE \u5f0f\r\n  WHEN \u50241 THEN\r\n    \u50241\u306e\u5834\u5408\u306e\u51e6\u7406;\r\n  WHEN \u50242 THEN\r\n    \u50242\u306e\u5834\u5408\u306e\u51e6\u7406;\r\n  ELSE\r\n    \u305d\u306e\u4ed6\u306e\u5834\u5408\u306e\u51e6\u7406;\r\nEND CASE;<\/pre>\n<p>CASE\u6587\u3067\u306f\u3001<span style=\"color: #ff0000;\"><strong>ELSE\u3092\u7701\u7565\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u304c\u3001\u3082\u3057\u6761\u4ef6\u306b\u4e00\u81f4\u3057\u306a\u3044\u5834\u5408\u306f\u3001\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/strong><\/span><\/p>\n<p>\u3082\u3057\u3001<span style=\"color: #ff0000;\"><strong>ELSE\u306e\u5834\u5408\u306b\u4f55\u3082\u3057\u305f\u304f\u306a\u3044\u5834\u5408\u306f\u3001\u300cNULL;\u300d\u3068\u8a18\u8ff0\u3057\u307e\u3057\u3087\u3046\u3002<\/strong><\/span><\/p>\n<h3>\u4f8b\u6587<\/h3>\n<pre class=\"lang:default decode:true \">DECLARE\r\n  num NUMBER := 2;\r\nBEGIN\r\n  CASE num\r\n    WHEN 1 THEN\r\n  \t  DBMS_OUTPUT.PUT_LINE('1\u306b\u4e00\u81f4\u3057\u3066\u3044\u307e\u3059\u3002');\r\n    WHEN 2 THEN\r\n    \tDBMS_OUTPUT.PUT_LINE('2\u306b\u4e00\u81f4\u3057\u3066\u3044\u307e\u3059\u3002');\r\n    ELSE\r\n    \tNULL; --\u4f55\u3082\u3057\u306a\u3044\u3002\r\n  END CASE;\r\nEND;<\/pre>\n","protected":false},"excerpt":{"rendered":"PL\/SQL\u3067\u306e\u6761\u4ef6\u5206\u5c90\u306e\u4ed5\u65b9\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002 \u666e\u901a\u306e\u6761\u4ef6\u5206\u5c90 \u69cb\u6587 IF \u6761\u4ef6 THEN \u51e6\u7406; END IF; \u4f8b\u6587 DECLARE num NUMBER := 2; BEGIN IF num = 2 THEN DB [&hellip;]","protected":false},"author":1,"featured_media":3108,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20,24],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/3103"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3103"}],"version-history":[{"count":4,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/3103\/revisions"}],"predecessor-version":[{"id":3107,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/3103\/revisions\/3107"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/media\/3108"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3103"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}