I want a stored function like so:
create function myFunction (someSwitch boolean)
return ...
is
cursor myCursor (params) is
[BIG QUERY];
...
Where the BIG QUERY can have an extra WHERE clause if someSwitch is true.
Can this be done within the cursor definition and, if so, how? Otherwise, what would be my options: I'm thinking that I could either create two cursors (one with the extra clause, the other without) and then do the logic in the function body. I'm not very satisfied by this approach as the query is very big and I would want to avoid repeating code. Alternatively, I could create the cursor SQL dynamically; but this would incur a performance degradation, right?
Thanks :)