{"id":3109,"date":"2018-05-21T00:26:09","date_gmt":"2018-05-20T15:26:09","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=3109"},"modified":"2023-05-27T21:44:12","modified_gmt":"2023-05-27T12:44:12","slug":"%e3%80%90pl-sql%e3%80%91%e7%b9%b0%e3%82%8a%e8%bf%94%e3%81%97%e5%88%b6%e5%be%a1","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=3109","title":{"rendered":"\u3010PL\/SQL\u3011\u7e70\u308a\u8fd4\u3057\u5236\u5fa1"},"content":{"rendered":"<p>PL\/SQL\u3067\u3082\u3001\u3082\u3061\u308d\u3093\u7e70\u308a\u8fd4\u3057\u5236\u5fa1\u306f\u3042\u308a\u307e\u3059\u3002\u4e0b\u8a18\u306e3\u7a2e\u985e\u306e\u69cb\u6587\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<ul>\n<li>LOOP\u6587<\/li>\n<li>FOR\u30eb\u30fc\u30d7<\/li>\n<li>WHILE\u30eb\u30fc\u30d7<\/li>\n<\/ul>\n<h2>LOOP\u6587<\/h2>\n<h3>\u69cb\u6587<\/h3>\n<pre class=\"lang:default decode:true\">LOOP\r\n  EXIT [WHEN \u6761\u4ef6];\r\n  \u51e6\u7406;\r\nEND LOOP;<\/pre>\n<p><span style=\"color: #000000;\">\u5fc5\u305a\u3001EXIT\u53e5\u3067\u7d42\u4e86\u3055\u305b\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002\u3067\u306a\u3051\u308c\u3070\u3001<span style=\"color: #ff0000;\"><strong>\u7121\u9650\u30eb\u30fc\u30d7\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u6ce8\u610f<\/strong><\/span>\u3067\u3059\u3002<\/span><\/p>\n<h3>\u5b9f\u88c5\u4f8b<\/h3>\n<pre class=\"lang:default decode:true\">DECLARE\r\n  num NUMBER := 0;\r\nBEGIN\r\n  LOOP\r\n  \t  DBMS_OUTPUT.PUT_LINE(num || '\u500b\u76ee');\r\n      num := num + 1;\r\n      EXIT WHEN num &gt;= 10;\r\n  END LOOP;\r\nEND;<\/pre>\n<h2>FOR\u30eb\u30fc\u30d7<\/h2>\n<h3>\u6607\u9806\u3067\u30ab\u30a6\u30f3\u30c8\u30a2\u30c3\u30d7\u3055\u305b\u308b\u5834\u5408<\/h3>\n<h4>\u69cb\u6587<\/h4>\n<pre class=\"lang:default decode:true\">FOR \u30eb\u30fc\u30d7\u30ab\u30a6\u30f3\u30bf IN \u4e0b\u9650\u5024..\u4e0a\u9650\u5024 LOOP\r\n  \u51e6\u7406;\r\nEND LOOP;<\/pre>\n<h4>\u4f8b\u6587<\/h4>\n<pre class=\"lang:default decode:true\">BEGIN\r\n  FOR i IN 1..9 LOOP\r\n  \t  DBMS_OUTPUT.PUT_LINE(i || '\u500b\u76ee');\r\n  END LOOP;\r\nEND;<\/pre>\n<h3>\u964d\u9806\u3067\u30ab\u30a6\u30f3\u30c8\u30a2\u30c3\u30d7\u3055\u305b\u308b\u5834\u5408<\/h3>\n<h4>\u69cb\u6587<\/h4>\n<pre class=\"lang:default decode:true\">FOR \u30eb\u30fc\u30d7\u30ab\u30a6\u30f3\u30bf REVERSE IN \u4e0b\u9650\u5024..\u4e0a\u9650\u5024 LOOP\r\n  \u51e6\u7406;\r\nEND LOOP;<\/pre>\n<h4>\u4f8b\u6587<\/h4>\n<pre class=\"lang:default decode:true\">BEGIN\r\n \u3000FOR i IN REVERSE 1..9 LOOP\r\n \u3000\u3000DBMS_OUTPUT.PUT_LINE(i || '\u500b\u76ee');\r\n \u3000END LOOP;\r\nEND;<\/pre>\n<h2>WHILE\u30eb\u30fc\u30d7<\/h2>\n<h3>\u69cb\u6587<\/h3>\n<pre class=\"lang:default decode:true\">WHILE \u6761\u4ef6 LOOP\r\n  \u51e6\u7406;\r\nEND LOOP;<\/pre>\n<h3>\u4f8b\u6587<\/h3>\n<pre class=\"lang:default decode:true\">DECLARE\r\n  num NUMBER := 0;\r\nBEGIN\r\n  WHILE num &lt; 10 LOOP\r\n  \t  DBMS_OUTPUT.PUT_LINE(num || '\u500b\u76ee');\r\n      num := num + 1;\r\n  END LOOP;\r\nEND;<\/pre>\n<h2>\u5b9f\u884c\u7d50\u679c<\/h2>\n<p>\u4e0a\u8a18\u69cb\u6587\u306e\u3044\u305a\u308c\u306e\u7e70\u308a\u8fd4\u3057\u5236\u5fa1\u3067\u3082\u4e0b\u8a18\u306e\u3088\u3046\u306a\u7d50\u679c\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-3114\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/05\/for\u6587_\u5b9f\u884c\u7d50\u679c.png\" alt=\"\" width=\"281\" height=\"218\" \/><\/p>\n<p>\u305f\u3060\u3057\u3001FOR\u30eb\u30fc\u30d7\u306eREVERSE\u53e5\u3092\u4f7f\u3063\u305f\u5834\u5408\u3060\u3051\u306f\u964d\u9806\u306e\u4e0b\u8a18\u306e\u7d50\u679c\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-3117\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/05\/\u7e70\u308a\u8fd4\u3057\u5236\u5fa1_\u964d\u9806.png\" alt=\"\" width=\"260\" height=\"205\" \/><\/p>\n<h2>EXIT<\/h2>\n<p>\u30eb\u30fc\u30d7\u3092\u7d42\u4e86\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u69cb\u6587\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">BEGIN\r\n    FOR i IN 1..3 LOOP\r\n        IF i = 2 THEN \r\n            EXIT;\r\n        END IF;\r\n    END LOOP;\r\nEND;<\/pre>\n<h2>CONTINUE<\/h2>\n<p>\u30eb\u30fc\u30d7\u51e6\u7406\u30921\u3064\u30b9\u30ad\u30c3\u30d7\u3067\u304d\u308b\u69cb\u6587\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">BEGIN\r\n    FOR i IN 1..3 LOOP\r\n        IF i = 2 THEN \r\n            CONTINUE;\r\n        END IF;\r\n    END LOOP;\r\nEND;<\/pre>\n<p>\u4e0a\u8a18\u30b5\u30f3\u30d7\u30eb\u3067\u306f3\u56de\u30eb\u30fc\u30d7\u3092\u56de\u3057\u30662\u306e\u6642\u3060\u3051\u30b9\u30ad\u30c3\u30d7\u3055\u305b\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"PL\/SQL\u3067\u3082\u3001\u3082\u3061\u308d\u3093\u7e70\u308a\u8fd4\u3057\u5236\u5fa1\u306f\u3042\u308a\u307e\u3059\u3002\u4e0b\u8a18\u306e3\u7a2e\u985e\u306e\u69cb\u6587\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002 LOOP\u6587 FOR\u30eb\u30fc\u30d7 WHILE\u30eb\u30fc\u30d7 LOOP\u6587 \u69cb\u6587 LOOP EXIT [WHEN \u6761\u4ef6]; \u51e6\u7406; END LOOP; [&hellip;]","protected":false},"author":1,"featured_media":3120,"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\/3109"}],"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=3109"}],"version-history":[{"count":11,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/3109\/revisions"}],"predecessor-version":[{"id":20394,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/3109\/revisions\/20394"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/media\/3120"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3109"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}