INSERT INTO T1(ID)
WITH RECURSIVE T(N) AS (
  SELECT 1
  UNION ALL
  SELECT N + 1 FROM T WHERE N < 10
)
SELECT N FROM T

I want to producuce multiple rows and insert those into a table.

The goal is to create a calendartable, but H2 does not accept the SQL above.

I succeed in my db2 database though. Se below. Could someone please help 
med ?
BR
/David



create table uppfoljning.KALENDER
( KALENDERDATUM timestamp not null
);

CREATE UNIQUE INDEX KALENDER_IX1 ON UPPFOLJNING.KALENDER
(
   KALENDERDATUM
)
;
ALTER TABLE UPPFOLJNING.KALENDER ADD CONSTRAINT KALENDER_PK PRIMARY KEY 
(
KALENDERDATUM
)
;


insert into uppfoljning.KALENDER WITH RECURSIVE cte_datetime(tms)
AS 
( 
    select DATEADD('DAY', 1, '2000-01-01')
    union all
    SELECT DATEADD('DAY', 1, tms)
    FROM cte_datetime 
    WHERE tms < DATE '2030-12-31'
) select tms from cte_datetime
;

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to