LoginSignup
2

More than 5 years have passed since last update.

Oracleの再帰With句でズンドコキヨシ

Posted at

Oracle11gR2から使える、再帰With句で作りました。

with rec(LV,ZunDokoStr) as(
select 0,Cast(Null as VarChar2(4000))
  from dual
union all
select LV+1,
ZunDokoStr || decode(Mod(Dbms_Crypto.RandomNumber,2),1,'ズン!','ドコ!')
  from rec
 where LV = 0 or ZunDokoStr Not Like '%ズン!ズン!ズン!ズン!ドコ!')
select ZunDokoStr || 'キ・ヨ・シ!' as "ズンドコキヨシ"
from (select LV,Max(LV) over() as MaxLV,ZunDokoStr
      from rec)
where LV = MaxLV;

ズンドコキヨシ
------------------------------------------------------------------
ドコ!ズン!ドコ!ズン!ズン!ズン!ズン!ズン!ドコ!キ・ヨ・シ!

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