我正在 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;
谢谢!