I have a task. I have to create a query that has optional elements for a where clause. This code is needed in a few different places so I fuigured a function to create a cursor wouold be best. So I have:
Now the complexity is the inputs above affect my where clause, but are all optional. So I could have none of them specified (ie null) or any combination of them (ie status = 'update', user='benny'). I may also add other elements in the future. So my question is how do I do this in PL/SQL? In any other real programming language I would create my select call in a string and then conditionally append to the where clause, then execute the statement. But I am not sure PL/SQL has this capability. Any suggestions?
Code:
FUNCTION get_info ( p_status IN VARCHAR2, p_user IN VARCHAR2, p_type IN VARCHAR2 ) RETURN SYS_REFCURSOR;
Comment