Re: Self documenting program in SQL
Date: 20 May 2005 12:21:54 -0700
Message-ID: <1116616914.937901.139770_at_g44g2000cwa.googlegroups.com>
Vadim Tropashko wrote:
> Did anybody write a query that duplicates itself as an output in SQL
> yet? In the list of languages at
>
> http://www.nyx.net/~gthompso/quine.htm
>
> SQL is absent. No cheating, please, like the one below exploring
> implementation quirks of specific database client program (SQL*Plus):
>
> SQL> SP2-0734: unknown command beginning "SP2-0734: ..." - rest of
line
> ignored.
> SP2-0734: unknown command beginning "SP2-0734: ..." - rest of line
> ignored.
Following steps in the cookbook (well, cookarticle) http://www.cgl.uwaterloo.ca/~csk/washington//paper/toc.html here is some approximation:
select a from (
select sys_connect_by_path('select a from ( select
sys_connect_by_path(', '/')||
sys_connect_by_path('a, level l dual connect by level < 3) where l = 2', '/')
a, level l from dual
connect by level < 3
) where l = 2
;
output
/select a from ( select sys_connect_by_path(/select a from ( select sys_connect_by_path(/a, level l dual connect by level < 3) where l = 2/a, level l dual connect by level < 3) where l = 2
I suspect recursive SQL solution should be cleaner. Received on Fri May 20 2005 - 21:21:54 CEST