2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PL/SQL で ズンドコキヨシ

Last updated at Posted at 2016-03-13

ズンドコキヨシまとめ
http://qiita.com/shunsugai@github/items/971a15461de29563bf90

と云う訳(?)で PL/SQL で ズンドコキヨシ を作って見た。

(力技で)すまんな。彡(-)(-)
ワンライナーでやっている猛者も何人か居るけど、
ワイにはこれ位が限界や……彡(-)(-)

SET SERVEROUTPUT ON SIZE UNLIMITED;
DECLARE
  -- Define
  vStr VARCHAR2(50);
BEGIN
  -- Initialize
  DBMS_RANDOM.SEED(TO_CHAR(SYSTIMESTAMP, 'YYYY/MM/DD HH24:MI:SS.FF'));
  -- ZunDoko Loop
  LOOP
    -- Zun or Doko
    vStr := vStr || CASE MOD(TRUNC(DBMS_RANDOM.VALUE*10), 2) WHEN 0 THEN 'ズン!' ELSE 'ドコ!' END;
    -- Cut and Format
    IF LENGTH(vStr) > 15 THEN
      vStr := SUBSTR(vStr, -15);
    END IF;
    -- Output
    DBMS_OUTPUT.PUT_LINE(vStr);
    -- Complete
    EXIT WHEN vStr = 'ズン!ズン!ズン!ズン!ドコ!';
  END LOOP;
  -- Kiyoshi!
  DBMS_OUTPUT.PUT_LINE('キ・ヨ・シ!');
END;
/

実行結果のサンプルは以下の通りやで彡(゚)(゚)

SQL> SET SERVEROUTPUT ON SIZE UNLIMITED;
SQL> DECLARE
  2    -- Define
  3    vStr VARCHAR2(50);
  4  BEGIN
  5    -- Initialize
  6    DBMS_RANDOM.SEED(TO_CHAR(SYSTIMESTAMP, 'YYYY/MM/DD HH24:MI:SS.FF'));
  7    -- ZunDoko Loop
  8    LOOP
  9      -- Zun or Doko
 10      vStr := vStr || CASE MOD(TRUNC(DBMS_RANDOM.VALUE*10), 2) WHEN 0 THEN 'ズン!' ELSE 'ドコ!' END;
 11      -- Cut and Format
 12      IF LENGTH(vStr) > 15 THEN
 13        vStr := SUBSTR(vStr, -15);
 14      END IF;
 15      -- Output
 16      DBMS_OUTPUT.PUT_LINE(vStr);
 17      -- Complete
 18      EXIT WHEN vStr = 'ズン!ズン!ズン!ズン!ドコ!';
 19    END LOOP;
 20    -- Kiyoshi!
 21    DBMS_OUTPUT.PUT_LINE('キ・ヨ・シ!');
 22  END;
 23  /
ズン!
ズン!ズン!
ズン!ズン!ドコ!
ズン!ズン!ドコ!ズン!
ズン!ズン!ドコ!ズン!ドコ!
ズン!ドコ!ズン!ドコ!ドコ!
ドコ!ズン!ドコ!ドコ!ズン!
ズン!ドコ!ドコ!ズン!ドコ!
ドコ!ドコ!ズン!ドコ!ドコ!
ドコ!ズン!ドコ!ドコ!ズン!
ズン!ドコ!ドコ!ズン!ドコ!
ドコ!ドコ!ズン!ドコ!ズン!
ドコ!ズン!ドコ!ズン!ズン!
ズン!ドコ!ズン!ズン!ドコ!
ドコ!ズン!ズン!ドコ!ドコ!
ズン!ズン!ドコ!ドコ!ズン!
ズン!ドコ!ドコ!ズン!ズン!
ドコ!ドコ!ズン!ズン!ズン!
ドコ!ズン!ズン!ズン!ズン!
ズン!ズン!ズン!ズン!ズン!
ズン!ズン!ズン!ズン!ズン!
ズン!ズン!ズン!ズン!ズン!
ズン!ズン!ズン!ズン!ズン!
ズン!ズン!ズン!ズン!ドコ!
キ・ヨ・シ!

PL/SQL procedure successfully completed.

SQL>

でももうちょっとスマートにやりたいやね彡(゚)(゚)

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?