Zitat Zitat von B.Hauser
Commont Table Expressions gehören zum SELECT statement und zu keinem anderen Statement.
Ein vollständiges SELECT-Statement besteht aus Common Table Expressions und einem Full-Select.

Wenn Du also Sätze in eine bestehende Datei einfügen willst,
musst du das komplette Select-Statement (mit allen CTEs) innerhalb des Inserts angeben:

Beispiel:
PHP-Code:
insert into MySchema/MyTable
with x 
as (select  count(*) as AnzABRABRTEXT as Text   
              from ABRECHVGL a  join KBELEG b            
                on     a
.ABRKBEKY KBELFDNR             
             where KBEWANR 
18800 and KBEVNR 1        
             group by ABRABRTEXT
),                   
     
as (select  Anz as yAnzText as yText,           
                   
digits(Anzconcat Text as yKey       
              from x
),                                   
     
as (select  Anz as zAnzText as zText,           
                   
digits(Anzconcat Text as zKey       
              from x
)                                    
select yAnzyTextcount(zKey) as Zaehler               
  from y  inner join z                                   
    on yKey 
>= zKey                                      
  group by yAnz
yText 
Birgitta
Vielen Dank, hat mich wieder ein großes Stück weiter gebracht.