Previous Topic Next topic Print topic


COBCH1644 Cannot use KEY phrase with WRITE statement applied to lists

The KEY phrase has been specified for a WRITE statement that is applied to a list.

You cannot use the KEY phrase in these circumstances, but you can use the KEY phrase with the REWRITE statement, which enables you to write to a specific location in your list.

class-id ListsClass.      
method-id listsDemo.
procedure division.
declare stringList as list[string]
create stringList

perform varying i as binary-long from 1 by 1 until i > 5
               write stringList from "item " & i
end-perform

write stringlist from "New item" key 2    *> this is incorrect
rewrite stringlist from "New item" key 2  *> but this will update list at key 2

end method.

end class.
Previous Topic Next topic Print topic