Why do I get "A cursor with the name already exists"? Why do I get "A cursor with the name already exists"? sql sql

Why do I get "A cursor with the name already exists"?


You are using global cursor that will be defined each time you are calling this procedure and give you the same error.

Define a local cursor. Just put the keyword LOCAL after CURSOR:

declare detailsCursor CURSOR LOCAL FOR...