本文发表在 rolia.net 枫下论坛Database server = DB2/NT 8.2.0
SQL authorization ID =
Local database alias =
db2 => with temptbl (num,str) as (select * from (values (1,'abcdefg')) as T unio
n all select num+1, substr('abcdefg', 1, length('abcdefg')-num) from temptbl wh
ere num<length('abcdefg') ) select * from temptbl
NUM STR
----------- -------
SQL0347W The recursive common table expression "TEMPTBL" may contain
an infinite loop. SQLSTATE=01605
1 abcdefg
2 abcdef
3 abcde
4 abcd
5 abc
6 ab
7 a
7 record(s) selected with 1 warning messages printed.
db2 =>
====================================================
Database server = DB2 OS/390 7.1.2
SQL authorization ID =
Local database alias =
db2 => with temptbl (num,str) as (select * from (values (1,'abcdefg')) as T unio
n all select num+1, substr('abcdefg', 1, length('abcdefg')-num) from temptbl wh
ere num<length('abcdefg') ) select * from temptbl
SQL0104N An unexpected token "(" was found following "". Expected tokens may
include: "IS <HEXSTRING> <CHARSTRING> <GRAPHSTRING> ". SQLSTATE=42601
db2 =>更多精彩文章及讨论,请光临枫下论坛 rolia.net
SQL authorization ID =
Local database alias =
db2 => with temptbl (num,str) as (select * from (values (1,'abcdefg')) as T unio
n all select num+1, substr('abcdefg', 1, length('abcdefg')-num) from temptbl wh
ere num<length('abcdefg') ) select * from temptbl
NUM STR
----------- -------
SQL0347W The recursive common table expression "TEMPTBL" may contain
an infinite loop. SQLSTATE=01605
1 abcdefg
2 abcdef
3 abcde
4 abcd
5 abc
6 ab
7 a
7 record(s) selected with 1 warning messages printed.
db2 =>
====================================================
Database server = DB2 OS/390 7.1.2
SQL authorization ID =
Local database alias =
db2 => with temptbl (num,str) as (select * from (values (1,'abcdefg')) as T unio
n all select num+1, substr('abcdefg', 1, length('abcdefg')-num) from temptbl wh
ere num<length('abcdefg') ) select * from temptbl
SQL0104N An unexpected token "(" was found following "". Expected tokens may
include: "IS <HEXSTRING> <CHARSTRING> <GRAPHSTRING> ". SQLSTATE=42601
db2 =>更多精彩文章及讨论,请光临枫下论坛 rolia.net