再帰処理をSQLで記述する Write recursive processing in SQL
再帰SQLの例題は「ハノイの塔」です
MMMの練習用に作ってみました 。
呼吸動作が思うように出来ませんでした。
動画作製に使用したソフト :
MikuMikuMoving V2 → sm31700304
LipSynchloid → sm22506025
DeleteFramePlugin → sm19579320
モーション・ポーズ連結ツール → sm25940359
RandomBlinkPlugin改 → https://twitter.com/aice_black/status/438305238236139521
AviUtl → http://spring-fragrance.mints.ne.jp/aviutl/
x264guiEx → https://rigaya34589.blog.fc2.com/
PostgreSQL → https://www.postgresql.org/
使用したコンテンツ :
ハノイの塔7段 → https://www.youtube.com/watch?v=TY8Uxzo--Nw
東北ずん子のイラスト/3Dデータ → https://zunko.jp/con_illust.html
■作製したSQL
※<>は半角に変換してね
WITH RECURSIVE hanoi as (
select 5 as nokori,'a' as f,'b' as d,'c' as w, '' as syori, 1 as step, '001' as lank
union all
select nokori -1
,case s.step when 1 then f when 2 then '' when 3 then w end
,case s.step when 1 then w when 2 then '' when 3 then d end
,case s.step when 1 then d when 2 then '' when 3 then f end
,case s.step when 1 then '' when 2 then 'move lv' || nokori || ' from ' || f || ' to ' || d when 3 then '' end
,s.step
,hanoi.lank || ',' || to_char(s.step,'000')
from hanoi
inner join (
select 1 as step
union all
select 2 as step
union all
select 3 as step
) as s on ( hanoi.step <> 2 )
where nokori > 0
)
select * from hanoi
where step = 2
order by lank
;