Quote:
|
Originally Posted by krReddy
im curious to know what the below syntax does. Since this is a commomtable expression, which is new to me .
with mytable (temp ) as (values repeat('splendid',3))
select substr(temp || rtrim(coalesce(str,' ')),length(rtrim(coalesce(str,' ')))+1,len) from mytable
|
A CTE can be seen as a (one-time) view. So the above is conceptually equivalent to:
Code:
CREATE VIEW mytable AS
SELECT 'splendidsplendidsplendid' AS temp FROM sysibm.sysdummy1 ;
select substr(temp || rtrim(coalesce(str,' ')),
length(rtrim(coalesce(str,' ')))+1,
len)
from mytable
but without making the view visual in the catalog.
(This sould give an error at "str" and at "len", I believe.)