There must be some code missing from what you’ve shown, because the WHERE clause is incomplete. Note that it ends in an =. Let’s say that you have a variable of the same type as your key, named MYKEY. Simpler SQL for what you’ve shown would be:
Then, go on from the point at which you do the OPEN.