Conditionally define a Cursor
问题 I have a Procedure in Oracle that takes a varchar2 paramater. Based on the value of that parameter, I need to define a cursor. The cursor will operate on different tables based on the value of the parameter. I wanted to do something like below but it throws an error in the CURSOR definition piece of code. Any ideas? PROCEDURE GET_RECORDS(v_action IN VARCHAR2) IS CURSOR get_records IS IF(v_action = 'DO THIS') THEN SELECT * from <THIS>; ELSE SELECT * from <THAT>; END IF; BEGIN OPEN get_records;