テーブルが空の場合にのみ値をテーブルに挿入するプロシージャを db2 で作成しています。次のステートメントを作成しましたが、エラーが発生しているため、何かが間違っています:
[42601][-104] An unexpected token "END-OF-STATEMENT" was found
following "END FOR".
Expected tokens may include: " END IF".. SQLCODE=-104, SQLSTATE=42601,
DRIVER=4.7.85
create or REPLACE PROCEDURE proc1
BEGIN
IF (exists (select 1 from table1)) then
TRUNCATE TABLE table1;
ELSE
FOR l1 as
select id, max(bla) as bla from table2 group by id
do
insert into table1 (column1, column2)
values (id, bla);
END FOR;
END IF;
END;
ありがとう!