Saturday, September 13, 2014

Oracle SQL -- A Quine

Problem

You need a quine written in Oracle SQL without using the CHR function.

For more information on quines see https://en.wikipedia.org/wiki/Quine_(computing)

Solution

WITH t AS (SELECT '''' a FROM dual), t1 AS (SELECT 'with t as (select a from dual), t1
select substr(t1.a,1,18)||t.a||t.a||t.a||t.a||substr(t1.a,18,17)
||substr(t1.a,7,12)||t.a||substr(t1.a,1,17)||substr(t1.a,18)||t.a||substr(t1.a,18,13)
||substr(t1.a,36)
from t,t1;
' a FROM dual)
SELECT substr(t1.a,1,18)||t.a||t.a||t.a||t.a||substr(t1.a,18,17)
||substr(t1.a,7,12)||t.a||substr(t1.a,1,17)||substr(t1.a,18)||t.a||substr(t1.a,18,13)
||substr(t1.a,36)
FROM t,t1;

No comments: