0
votes
--/
BEGIN
     FOR V AS MYCURSOR CURSOR FOR SELECT ID,NAME,AGE FROM PEOPLE
     DO
        BEGIN
            INSERT INTO PERSON(NAME,AGE) VALUES(V.NAME,V.AGE);
        END;
     END FOR;
END;
/

DB tool is Dbvisualizer 10.0.1, so I need "--/" and "/"

Message: [Code: -104, SQL State: 42601] An unexpected token "V" was found following "BEGIN FOR ". Expected tokens may include: "JOIN".. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.22.29 Help plz.

1
What’s the Db2 version and platform? Have you tried to find the place in DBVisualizer, where you can change the statement delimiter from ; to /?Mark Barinstein
Your code fragment works correctly in my DbVisualizer , but I have the current version of Dbviz - consider installing the latest build ( 10.0.24). Otherwise your code fragment differs from what Db2 is getting.mao

1 Answers

0
votes

In your query tool, set the statement terminator to something that is not ';'. E.g. use @

BEGIN
 FOR V AS MYCURSOR CURSOR FOR SELECT ID,NAME,AGE FROM PEOPLE
 DO
    BEGIN
        INSERT INTO PERSON(NAME,AGE) VALUES(V.NAME,V.AGE);
    END;
 END FOR;
END
@