Re: WITH RECURSIVE ... simplified syntax?
От | Dickson S. Guedes |
---|---|
Тема | Re: WITH RECURSIVE ... simplified syntax? |
Дата | |
Msg-id | 48ED735E.1060008@gmail.com обсуждение исходный текст |
Ответ на | WITH RECURSIVE ... simplified syntax? (Josh Berkus <josh@agliodbs.com>) |
Список | pgsql-hackers |
Josh Berkus escreveu: > All, > > I was discussing WITH RECURSIVE the other day, and realized that one thing > which we're not getting with this patch is a simplest-case simple syntax > which 75% of users are looking for. You know, the ones with simple > proximity trees who just want to find all children of one parent. > > Would it be a worth it for us to implement a non-standard simple syntax > sugar on top of WITH RECURSIVE? Or, at least, something like > CONNECT_BY() Yes Josh, I was discussing WITH RECURSIVE with some students that I'm teaching and they ask me exactly this: "Why not use a syntax like... SELECT level, lpad(' ', level*4) || last_name as last_name FROM employee START WITH employee_id = 10 CONNECT BY PRIOR employee_id = manager_id; ... that is rewrite (or aliased) in: WITH RECURSIVE employee_rec(level, employee_id, last_name) AS (SELECT 1, employee_id, last_name) FROMemployee WHERE employee_id = 10 UNION ALL SELECT employee_rec.level + 1, emp.employee_id,emp.last_name FROM employee as emp, employee_rec WHERE employee_rec.employee_id= emp.manager_id) SELECT level, lpad(' ', level*4) || last_name FROM employee_rec;" ? In my opnion, it will be more simple to understand too. -- []s Dickson S. Guedes Administrador de Banco de Dados Projeto Colmeia - Florianópolis, SC (48) 3322-1185, ramal: 26
В списке pgsql-hackers по дате отправления: